Open ydaveluy opened 4 months ago
We have a validation for protecting against name collisions with the JavaScript runtime. See here. We would need a separate list for reserved names of the Langium imports.
Another alternative would be to import types with a specific prefix (e.g. _langium_
) and to prohibit rule names in the grammar from starting with this prefix ?
e.g:
import type { AstNode as _langium_AstNode,
Reference as _langium_Reference,
ReferenceInfo as _langium_ReferenceInfo,
TypeMetaData as _langium_TypeMetaData } from 'langium';
I don't know if this concept would be valid for other reserved keywords.
When defining in mydsl.langium file an interface named Reference, the generated ast.ts does not compile.
Langium version: 3.1 Package name: langium
Steps To Reproduce
1. define an interface named 'Reference' in mydsl.langium
2.
Build the project
The current behavior
The project fails to build due to a conflict with imported types from langium in src/language/generated/ast.ts:
import type { AstNode, Reference, ReferenceInfo, TypeMetaData } from 'langium';
The expected behavior
Definition of interfaces like AstNode, Reference, ReferenceInfo or TypeMetaData in langium file should not collide with imports.