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

Make comma-list parsing really robust #403

Merged
merged 5 commits into from
Jan 9, 2025
Merged

Make comma-list parsing really robust #403

merged 5 commits into from
Jan 9, 2025

Conversation

mcy
Copy link
Member

@mcy mcy commented Dec 19, 2024

This PR adds more diagnostics for comma-delimited list of types and expressions, and ensures that commas are optional pretty much everywhere for generating a valid AST, while at the same time diagnosing all missing and extraneous commas. This ensures a match with the behavior advertised in #393.

Includes a test that exercises various corner cases.

This PR also adds Span.RuneRange and Span.Rune, to aid in constructing suggestion spans.

@mcy mcy requested a review from jhump December 19, 2024 20:29
@mcy mcy requested a review from jhump January 7, 2025 20:06
//
// If we don't do this, message will be interpreted as an
// expression.
return !first && t.Kind() == token.Ident
Copy link
Member

Choose a reason for hiding this comment

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

This might be worth a TODO since editions uses identifiers instead of strings for reserved field names. So this means that reserved foo, bar baz will treat baz as a new decl, which is less than ideal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Figured out a way to resolve this w/o affecting the happy path.

@mcy mcy enabled auto-merge (squash) January 9, 2025 17:59
@mcy mcy merged commit 0baecbe into main Jan 9, 2025
8 checks passed
@mcy mcy deleted the mcy/parse-expr-followups branch January 9, 2025 18:03
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