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

Fix references in fragment rules #1762

Merged
merged 3 commits into from
Dec 11, 2024
Merged

Conversation

msujew
Copy link
Member

@msujew msujew commented Nov 28, 2024

This is a fix for an issue exposed in #1638.

Essentially, this is caused by the combination of cross references, actions and fragment rule calls. The main culprit is that we temporarily create AST nodes for fragment rule calls (which wasn't really necessary in the first place) and then use those temporary elements for the Reference object. As these AST nodes never get into the final AST, they don't have a document reference and result in errors during the scoping phase.

This change simply removes the temporary AST element, and lets the parser assign the properties to the original AST node that called the fragment rule.

Testing this fix requires a more complicated testing setup, but hopefully the comment explains this well enough.

@msujew msujew added bug Something isn't working parser Parser related issue labels Nov 28, 2024
@msujew msujew force-pushed the msujew/fix-fragment-references branch from 053e916 to 18662c3 Compare December 2, 2024 12:32
Copy link
Contributor

@sailingKieler sailingKieler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Mark,
I have a few remarks & questions, nothing spectacular, mainly to make a bit clearer what's going on.

I would appreciate to see one or two more test cases addressing potentially problematic cases with fragments+cross-references for the sake of documentation and future stability.

packages/langium/src/parser/langium-parser.ts Outdated Show resolved Hide resolved
packages/langium/src/parser/langium-parser.ts Outdated Show resolved Hide resolved
packages/langium/src/parser/langium-parser.ts Outdated Show resolved Hide resolved
@msujew msujew force-pushed the msujew/fix-fragment-references branch from 18662c3 to 90b37e1 Compare December 9, 2024 11:41
@msujew msujew force-pushed the msujew/fix-fragment-references branch from 90b37e1 to 5288bb3 Compare December 9, 2024 11:43
@msujew
Copy link
Member Author

msujew commented Dec 9, 2024

@sailingKieler Thanks for the review. I've added an additional test case for this.

@msujew msujew merged commit 88f176c into main Dec 11, 2024
5 checks passed
@msujew msujew deleted the msujew/fix-fragment-references branch December 11, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Parser related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants