Skip to content

Fix parsing errors using anonymous records and units of measures #18543

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

Merged
merged 32 commits into from
May 22, 2025

Conversation

edgarfgp
Copy link
Contributor

@edgarfgp edgarfgp commented May 11, 2025

Description

Essentially the lexer could not understand >|}. So I followed the same approach that the existing >|] handles this and then checked that in both cases produce the same AST.

Fixes #10629

{|a=1<m>|} 
{|a= 1<m> |}

BEFORE

(1,9) (1, 10)error3156parse
Unexpected token '|' or incomplete expression

(1,10) (1, 11)error10parse
Unexpected symbol '}' in definition. Expected '|}' or other token.

(1,1) (1, 3)error605parse
Unmatched '{|'

AFTER

Expr
    (AnonRecd
    (false, None,
     [(SynLongIdent ([a], [], [None]), Some (7,4--7,5),
       Const
         (Measure
            (Int32 1, (7,5--7,6),
             Seq ([Named ([m], (7,7--7,8))], (7,7--7,8)),
             { LessRange = (7,6--7,7)
               GreaterRange = (7,8--7,9) }), (7,5--7,9)))],
     (7,0--7,11), { OpeningBraceRange = (7,0--7,2) }), (7,0--7,11));

Checklist

  • Test cases added
  • Release notes entry updated

Copy link
Contributor

github-actions bot commented May 11, 2025

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/10.0.100.md
LanguageFeatures.fsi docs/release-notes/.Language/preview.md

@edgarfgp edgarfgp changed the title Fix invalid syntax around anonymous type and units of measures Fix invalid syntax around anonymous records and units of measures May 11, 2025
@edgarfgp edgarfgp changed the title Fix invalid syntax around anonymous records and units of measures Fix parsing errors using anonymous records and units of measures May 11, 2025
@edgarfgp edgarfgp marked this pull request as ready for review May 11, 2025 21:22
@edgarfgp edgarfgp requested a review from a team as a code owner May 11, 2025 21:22
@T-Gro T-Gro enabled auto-merge (squash) May 16, 2025 11:26
auto-merge was automatically disabled May 19, 2025 18:19

Head branch was pushed to by a user without write access

@edgarfgp
Copy link
Contributor Author

Fixed again another merge conflict :(

@edgarfgp
Copy link
Contributor Author

@T-Gro This is ready

Copy link
Member

@T-Gro T-Gro left a comment

Choose a reason for hiding this comment

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

Thanks for finishing this @edgarfgp .
I do realize that my wishes to guard even simple improvements can be annoying at times, but our focus should be at the user who does not watch language evolution closely.

The situation with up-to-date local and outdated CI is quite real.When it comes to parser/lexer improvememnts, those errors (not reproducible locally) would be confusing (well, as they are currently before this change...) and hard to fix blindly.

@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling May 22, 2025
@T-Gro T-Gro enabled auto-merge (squash) May 22, 2025 08:12
@T-Gro T-Gro merged commit 10c07b3 into dotnet:main May 22, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in F# Compiler and Tooling May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

better error recovery / invalid syntax around anonymous type and units of measure literal
3 participants