langium icon indicating copy to clipboard operation
langium copied to clipboard

Misleading type compatibility validation error

Open dhuebner opened this issue 2 years ago • 0 comments

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.

dhuebner avatar Nov 02 '23 14:11 dhuebner