Where the type checking function should be called #766
-
Hey guys, I'm working on the type system of my DSL. Both the document and #706 suggest that the type checking process should take place after
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
TypeScript supports interface declaration merging, so you can simply add optional properties to
Usually linking takes place in the linking phase, which visits all cross-references in the document and tries to resolve them. But in case you add a callback between scope computation and linking, and your function accesses the
Yes, I would actually start with such a lazy approach because it's simpler. Computing types as part of the build process and storing type information with the document is a performance optimization to avoid computing the same information twice. But as always with optimization, I would not do it until you actually see performance problems. |
Beta Was this translation helpful? Give feedback.
-
In addition to what @spoenemann already said, there is a scoping guide in progress over at eclipse-langium/langium-website#79 (see this live link). It goes into more detail on how scoping/linking interacts with a type system, using the lox language as an example. Note that the actual "type checking" phase usually happens during validation, where we actually show errors for where the type checking/assignability check fails. During scoping we only perform type inference, not assignability checking. |
Beta Was this translation helpful? Give feedback.
TypeScript supports interface declaration merging, so you can simply add optional properties to
LangiumDocument
and assign / use them as you like.Usually linking takes place in the linking phase, which visits all cross-references in the document and tries to resolve them. But in case you add a callback between scope computation and linking, and your function accesses the
ref
property of a reference, lazy linking is triggered by such an access. So if your callback function produces inform…