Skip to content

"The assigned type is not compatible with the declared property" with enum-like type #2074

@ebousse

Description

@ebousse

Langium version: 4.1.0
Package name: ?

Steps To Reproduce

  1. Write the grammar below
  2. Run npm run langium:generate

Code example:

grammar HelloWorld

interface Root {
    color: Color
}

type Color = 'red' | 'blue' | 'green';


entry RootRule returns Root:
    'color' color=ColorRule
;

ColorRule returns Color:
    'red' | 'blue' | 'green'
;

hidden terminal WS: /\s+/;
hidden terminal ML_COMMENT: /\/\*[\s\S]*?\*\//;
hidden terminal SL_COMMENT: /\/\/[^\n\r]*/;

The current behavior

src/hello-world.langium:11:13 - The assigned type 'ColorRule' is not compatible with the declared property 'color' of type 'Color'.

Screenshot:
image

The expected behavior

The grammar should work without type error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions