-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consistency of type usage #429
Comments
We validate usages of types from declared types, we should validate also types from inferred types.
So, interface
|
@msujew I see you're still assigned to this after it was closed and reopened. Are you still interested in working on this one, or is it okay if I go for it? |
@montymxb Feel free to take this one 👍 |
@pluralia @msujew while working through this problem I had an idea I wanted to run by you both. Would it be considered reasonable to prevent interfaces from extending inferred types? And by extension, just saying that declared types cannot extend inferred types. I have some thoughts why this might be helpful:
In this way, you can make something explicit, but you cannot set it back by basing it on something inferred. I am trying to think if this restricts anything in terms of expressiveness, but I haven't come up with anything yet 🤔 . |
I agree with that, extending an inferred type with a declared type is weird and should not be supported. |
I like the idea, here is some thoughts.
We are going to implement the strict mode specially for the case.
We still have to do it for validation purposes. One of the most important advantages of Langium is the brief prototyping: you can write a couple of parser rules and everything works out of the box. Sometimes you need to add declared types in addition to this pair of parser rules for minimal type shaping, in which case it's no good to prohibit extending inferred types, because you would have to add more declared types, which goes against the idea of brief prototyping "as few entities in grammar as possible". Another point is that inferred and declared types will become semantically "unequal": declared types can be extended, while inferred types cannot. To summarize: I think we should do it in the strict mode only and allow it by default for brief prototyping. We shortly discussed this problem, and @montymxb suggested using warnings when inferred types are extended by declared types. I fully support this idea: we keep prototyping brief, but at the same time notify the user when a declared type is "unstable" and can be implicitly changed because of the parent inferred type. |
See #406 (comment): we should validate usages of
type
s for consistency. For example, this is not valid becauseFoo
is not an AST node type.The same applies to actions and extended interfaces.
The text was updated successfully, but these errors were encountered: