Closed montymxb closed 2 years ago
(Note: Code actions are an LSP request type, which is totally unrelated to actions in the grammar)
Not the same but related: #447
@montymxb
A is a declared type and cannot be inferred
I would like to propose: A is a declared type and cannot be redefined
As an additional note, I've noticed that in the following code there's a retrieval of distinct interfaces and unions (both inferred & declared) after they have been combined together. What strikes me as odd is that there's room for duplication, and that in such a case inferred types take precedence over declared due to the order of concatenation.
I'm not proposing that we necessary do something about this in this issue, since validation can take care of it before this point. But I am curious if we should be doing something other than simple concatenation of two different groups of interfaces & types. Even if we do proper validation before-hand, if something sneaks through this could pop up again in the same fashion.
But I am curious if we should be doing something other than simple concatenation of two different groups of interfaces & types.
As I understand it, the only thing we can do to be sure there are no errors at all is to repeat the validation. Since the validation is already done for the moment, I think we can leave this code as it is, at least until there is no other reason to improve it.
Actions can rewrite declared types, effectively erasing/changing their previously declared properties. This leads to an inability to reason about declared types as a fixed source of information about the resulting AST that is generated.
An example grammar in Langium that causes this:
assumes the ID terminal is declared
This generates the following interface, which is not correct:
Langium version: 0.3.0 (dev)
Instead:
A is a declared type and cannot be inferred
{infer A}
to{A}
(could potentially be in a separate PR)