langium
langium copied to clipboard
Cyclic inheritance of types
Some grammars produce cyclic inherited types. For example, these 2 grammars
A infers TypeA:
B ({infer TypeC.left=current} name=ID)*;
B infers TypeB:
'(' A ')' | {infer TypeD} value=NUMBER;
A infers TypeA:
B C*;
B infers TypeB:
'(' A ')' | D;
generate these types:
export type TypeA = TypeB | TypeC;
export type TypeB = TypeA | TypeD;
TypeA
here inherits TypeB
and TypeB
inherits TypeA
, what brings TS errors. We should forbid cyclic inheritance by a validation error.
The validation error should be shown for declared types, too:
type TypeA = TypeB | TypeC;
type TypeB = TypeA | TypeD;
I think I'm experiencing something like this problem myself. Is this issue still open?
@jtenner I've assigned you :)