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

Disambiguate const array literals from parenthesized primary expressions #292

Merged
merged 2 commits into from
Sep 9, 2024

Conversation

Cirras
Copy link
Collaborator

@Cirras Cirras commented Sep 9, 2024

This PR fixes a parsing bug where const array literal expressions would be confused with parenthesized primary expressions.

The official parser builds type information incrementally during parsing and relies on it to know what may appear on the right side of an assignment (which is another point in favor of #261).

With our current approach to parsing, the fix for this problem is a slightly gnarly repetition of rules in the ANTLR3 grammar.

@Cirras Cirras requested a review from jgardn3r September 9, 2024 00:56
@Cirras Cirras force-pushed the const_array_literals branch from a9a2936 to fa1c58e Compare September 9, 2024 04:35
@Cirras Cirras requested a review from jgardn3r September 9, 2024 05:40
Some of our `constExpression` usages were in places that couldn't
actually have an array or record literal.
Copy link
Collaborator

@jgardn3r jgardn3r left a comment

Choose a reason for hiding this comment

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

Looks good post rebase.

@Cirras Cirras force-pushed the const_array_literals branch from fa1c58e to f3fd2b9 Compare September 9, 2024 05:59
@Cirras Cirras requested a review from jgardn3r September 9, 2024 05:59
Copy link
Collaborator

@jgardn3r jgardn3r left a comment

Choose a reason for hiding this comment

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

Looks good!

@Cirras Cirras merged commit 1737bd6 into master Sep 9, 2024
2 checks passed
@Cirras Cirras deleted the const_array_literals branch September 9, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants