langium
langium copied to clipboard
Misleading type compatibility validation error
Langium version: 2.0.1 Package name: langium
Steps To Reproduce
grammar Foo
interface RuleType { prop : string };
entry Rule returns RuleType:
// Error at prop: The assigned type 'MyDataType' is not compatible with the declared property 'prop' of type 'string'.
prop = MyDataType
;
MyDataType returns string:
INT
;
terminal INT returns number: /[0-9]+/;
The current behavior
In the example above an error is reported because MyDataType uses a number typed terminal rule. Even thought the rule defines the return type string.
The expected behavior
Because the datatype rule defines its return type as string the error should not be created.