eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
663 stars 61 forks source link

Langium 3.1: Changes in inference #1540

Closed cdietrich closed 2 weeks ago

cdietrich commented 3 weeks ago

we have something like

Primary infers Expression:
    {infer Parenthesis} '(' expr=Expression ')' |
    ....
    NumberLiteral |
    BooleanLiteral |
    StringLiteral |
    ....

in our grammar.

with langium 3.1 we now see following compile error

src/grammars/generated/ast.ts(1615,18): error TS2320: Interface 'Parenthesis' cannot simultaneously extend types 'BooleanLiteral' and 'NumberLiteral'.
  Named property 'value' of types 'BooleanLiteral' and 'NumberLiteral' are not identical.
src/grammars/generated/ast.ts(1615,18): error TS2320: Interface 'Parenthesis' cannot simultaneously extend types 'BooleanLiteral' and 'StringLiteral'.
  Named property 'value' of types 'BooleanLiteral' and 'StringLiteral' are not identical.
export interface StringLiteral extends AstNode {
    readonly $container: .......;
    readonly $type: 'Parenthesis' | 'StringLiteral';
    value: string;
}

before in langium3 it was

export interface StringLiteral extends AstNode {
    readonly $container: ......;
    readonly $type: 'StringLiteral';
    value: string;
}

=> should the moveup also consider the type?

cdietrich commented 3 weeks ago

similar problem at other children with same name and different types. the parenthesis type basially gets spoiled into a lot of inferred types around expressions

this also happens with

Rule: {infer A} 'somekeyword' | B;