Skip to content
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

False positive in grammar multiple assignments validation #1756

Closed
cdietrich opened this issue Nov 20, 2024 · 3 comments · Fixed by #1766
Closed

False positive in grammar multiple assignments validation #1756

cdietrich opened this issue Nov 20, 2024 · 3 comments · Fixed by #1766
Assignees
Labels
bug Something isn't working

Comments

@cdietrich
Copy link
Contributor

Langium version: 3.3

given the grammar

entry Model:
    expr=Expression;

Expression: Equality;

Equality infers Expression:
    Literal (({infer Equals.left=current} '==' | {infer NotEquals.left=current} '!=')  right=Literal)*;

Literal: value=INT;

the validator complains about

src/language/hello-world.langium:9:88 - Found multiple assignments to 'right' with the '=' assignment operator. Consider using '+=' instead to prevent data loss.

imho this is a false positive with the ast rewrite. maybe it is not properly detected if happing on all branches of an alternative.

@cdietrich cdietrich added the bug Something isn't working label Nov 20, 2024
@cdietrich cdietrich changed the title False positive in grammar False positive in grammar multiple assignments validation Nov 20, 2024
@cdietrich
Copy link
Contributor Author

cc @JohannesMeierSE

@JohannesMeierSE JohannesMeierSE self-assigned this Nov 20, 2024
@JohannesMeierSE
Copy link
Contributor

@cdietrich thanks for the bug report! I will investigate it, but I will need to find some free time for that. Is it urgent on your side?

with the ast rewrite. maybe it is not properly detected if happing on all branches of an alternative

I agree: ( ... right=Literal )* looks critical for the validation. A check for creating new objects inside ( ... )* is probably the solution.

@JohannesMeierSE
Copy link
Contributor

@cdietrich I investigated the issue and created the PR #1766 for it: Rewrite actions were checked in general, but not all combinations of looped and nested rewrite actions.

JohannesMeierSE added a commit that referenced this issue Dec 11, 2024
…t now (#1766)

* recursively take created objects in groups/alternatives into account, added some more specific test cases
* simplified and reworked the validation to support actions as top-level elements in parser rules as well (was another bug)
* derived test cases from the discussion in #1756
* refactoring: inlined method
* improved error logging
msujew pushed a commit that referenced this issue Jan 23, 2025
…t now (#1766)

* recursively take created objects in groups/alternatives into account, added some more specific test cases
* simplified and reworked the validation to support actions as top-level elements in parser rules as well (was another bug)
* derived test cases from the discussion in #1756
* refactoring: inlined method
* improved error logging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants