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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
034d4d6
Add a new token GREATER_BAR_RBRACE
edgarfgp May 11, 2025
0745593
Update lex.fsl
edgarfgp May 11, 2025
120c02c
Update FSStrings
edgarfgp May 11, 2025
c87844d
Update ServiceLexing
edgarfgp May 11, 2025
afd4adf
Update CompilerDiagnostics
edgarfgp May 11, 2025
28cf61f
Update LexFilter
edgarfgp May 11, 2025
95180ae
Add SyntaxTree tests
edgarfgp May 11, 2025
15ec291
more tests
edgarfgp May 11, 2025
136c8b5
Merge branch 'main' into fix-10629
edgarfgp May 11, 2025
5d72ba9
Update baselines
edgarfgp May 11, 2025
046588c
Merge branch 'fix-10629' of github.com:edgarfgp/fsharp into fix-10629
edgarfgp May 11, 2025
306e18f
Add more tests
edgarfgp May 11, 2025
8ba39be
release notes
edgarfgp May 11, 2025
e0ef7df
ILVerify
edgarfgp May 11, 2025
729ebbb
more tests
edgarfgp May 11, 2025
52994ec
Merge branch 'main' into fix-10629
edgarfgp May 12, 2025
9d60b9c
Merge branch 'main' into fix-10629
edgarfgp May 13, 2025
d1db7d3
Merge branch 'main' into fix-10629
edgarfgp May 14, 2025
18e4fd1
Merge branch 'main' into fix-10629
edgarfgp May 15, 2025
d6457ed
update syntax tree tests
edgarfgp May 15, 2025
fa7cbd9
Add LanguageFeature BetterAnonymousRecordParsing
edgarfgp May 15, 2025
69ba907
release notes
edgarfgp May 15, 2025
2c5b65e
release notes
edgarfgp May 15, 2025
6ca06c5
update baselines
edgarfgp May 15, 2025
addd36a
Merge branch 'fix-10629' of github.com:edgarfgp/fsharp into fix-10629
edgarfgp May 15, 2025
3a6aa30
Merge branch 'main' into fix-10629
edgarfgp May 16, 2025
077f33a
Merge branch 'main' into fix-10629
T-Gro May 16, 2025
434662f
Merge branch 'main' into fix-10629
edgarfgp May 19, 2025
5ca1e99
update ILVerify tests
edgarfgp May 19, 2025
900927c
Merge branch 'main' into fix-10629
edgarfgp May 20, 2025
882b0bb
Merge branch 'main' into fix-10629
T-Gro May 22, 2025
72b7b9b
Merge branch 'main' into fix-10629
edgarfgp May 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/10.0.100.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
### Fixed

* Fix parsing errors using anonymous records and units of measures ([PR #18543](https://github.com/dotnet/fsharp/pull/18543))
* Fixed: Allow `return`, `return!`, `yield`, `yield!` type annotations without parentheses ([PR #18533](https://github.com/dotnet/fsharp/pull/18533))
* Allow `let!` and `use!` type annotations without requiring parentheses ([PR #18508](https://github.com/dotnet/fsharp/pull/18508))
* Fix find all references for F# exceptions ([PR #18565](https://github.com/dotnet/fsharp/pull/18565))
Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* Make `[<CallerMemberName; Struct>]` combination work([PR #18444](https://github.com/dotnet/fsharp/pull/18444/))
* Fix code completion considers types from own namespace non-imported ([PR #18518](https://github.com/dotnet/fsharp/issues/18518))
* Code completion: fix getting qualifier expression in do statements in type decls ([PR #18524](https://github.com/dotnet/fsharp/pull/18524))
* Fix parsing errors using anonymous records and units of measures ([PR #18543](https://github.com/dotnet/fsharp/pull/18543))
* Fixed: [#18441](https://github.com/dotnet/fsharp/issues/18441) FSI multi-emit unstable. ([PR #18465](https://github.com/dotnet/fsharp/pull/18465))
* Fixed: Allow `return`, `return!`, `yield`, `yield!` type annotations without parentheses ([PR #18533](https://github.com/dotnet/fsharp/pull/18533))

Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/.Language/preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Support ValueOption + Struct attribute as optional parameter for methods ([Language suggestion #1136](https://github.com/fsharp/fslang-suggestions/issues/1136), [PR #18098](https://github.com/dotnet/fsharp/pull/18098))
* Allow `_` in `use!` bindings values (lift FS1228 restriction) ([PR #18487](https://github.com/dotnet/fsharp/pull/18487))
* Warn when `unit` is passed to an `obj`-typed argument ([PR #18330](https://github.com/dotnet/fsharp/pull/18330))
* Fix parsing errors using anonymous records and units of measures ([PR #18543](https://github.com/dotnet/fsharp/pull/18543))
* Scoped Nowarn: added the #warnon compiler directive ([Language suggestion #278](https://github.com/fsharp/fslang-suggestions/issues/278), [RFC FS-1146 PR](https://github.com/fsharp/fslang-design/pull/782), [PR #18049](https://github.com/dotnet/fsharp/pull/18049))
* Allow `let!` and `use!` type annotations without requiring parentheses. ([PR #18508](https://github.com/dotnet/fsharp/pull/18508))

Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Driver/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ type Exception with
| Parser.TOKEN_COLON_EQUALS -> SR.GetString("Parser.TOKEN.COLON.EQUALS")
| Parser.TOKEN_LARROW -> SR.GetString("Parser.TOKEN.LARROW")
| Parser.TOKEN_EQUALS -> SR.GetString("Parser.TOKEN.EQUALS")
| Parser.TOKEN_GREATER_BAR_RBRACE -> SR.GetString("Parser.TOKEN.GREATER.BAR.RBRACE")
| Parser.TOKEN_GREATER_BAR_RBRACK -> SR.GetString("Parser.TOKEN.GREATER.BAR.RBRACK")
| Parser.TOKEN_MINUS -> SR.GetString("Parser.TOKEN.MINUS")
| Parser.TOKEN_ADJACENT_PREFIX_OP -> SR.GetString("Parser.TOKEN.ADJACENT.PREFIX.OP")
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,7 @@ featureDeprecatePlacesWhereSeqCanBeOmitted,"Deprecate places where 'seq' can be
featureSupportValueOptionsAsOptionalParameters,"Support ValueOption as valid type for optional member parameters"
featureSupportWarnWhenUnitPassedToObjArg,"Warn when unit is passed to a member accepting `obj` argument, e.g. `Method(o:obj)` will warn if called via `Method()`."
featureUseBangBindingValueDiscard,"Allows use! _ = ... in computation expressions"
featureBetterAnonymousRecordParsing,"Support for better anonymous record parsing"
featureScopedNowarn,"Support for scoped enabling / disabling of warnings by #warn and #nowarn directives, also inside modules"
featureAllowLetOrUseBangTypeAnnotationWithoutParens,"Allow let! and use! type annotations without requiring parentheses"
3874,lexWarnDirectiveMustBeFirst,"#nowarn/#warnon directives must appear as the first non-whitespace characters on a line"
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/FSStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@
<data name="Parser.TOKEN.EQUALS" xml:space="preserve">
<value>symbol '='</value>
</data>
<data name="Parser.TOKEN.GREATER.BAR.RBRACE" xml:space="preserve">
<value>symbol '&gt;|}'</value>
</data>
<data name="Parser.TOKEN.GREATER.BAR.RBRACK" xml:space="preserve">
<value>symbol '&gt;|]'</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ type LanguageFeature =
| SupportValueOptionsAsOptionalParameters
| WarnWhenUnitPassedToObjArg
| UseBangBindingValueDiscard
| BetterAnonymousRecordParsing
| ScopedNowarn
| AllowTypedLetOrUseBang

Expand Down Expand Up @@ -233,6 +234,7 @@ type LanguageVersion(versionText) =
LanguageFeature.SupportValueOptionsAsOptionalParameters, previewVersion
LanguageFeature.WarnWhenUnitPassedToObjArg, previewVersion
LanguageFeature.UseBangBindingValueDiscard, previewVersion
LanguageFeature.BetterAnonymousRecordParsing, previewVersion
LanguageFeature.ScopedNowarn, previewVersion
LanguageFeature.AllowTypedLetOrUseBang, previewVersion
]
Expand Down Expand Up @@ -398,6 +400,7 @@ type LanguageVersion(versionText) =
| LanguageFeature.SupportValueOptionsAsOptionalParameters -> FSComp.SR.featureSupportValueOptionsAsOptionalParameters ()
| LanguageFeature.WarnWhenUnitPassedToObjArg -> FSComp.SR.featureSupportWarnWhenUnitPassedToObjArg ()
| LanguageFeature.UseBangBindingValueDiscard -> FSComp.SR.featureUseBangBindingValueDiscard ()
| LanguageFeature.BetterAnonymousRecordParsing -> FSComp.SR.featureBetterAnonymousRecordParsing ()
| LanguageFeature.ScopedNowarn -> FSComp.SR.featureScopedNowarn ()
| LanguageFeature.AllowTypedLetOrUseBang -> FSComp.SR.featureAllowLetOrUseBangTypeAnnotationWithoutParens ()

Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Facilities/LanguageFeatures.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ type LanguageFeature =
| SupportValueOptionsAsOptionalParameters
| WarnWhenUnitPassedToObjArg
| UseBangBindingValueDiscard
| BetterAnonymousRecordParsing
| ScopedNowarn
| AllowTypedLetOrUseBang

Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/Service/ServiceLexing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ module internal TokenClassifications =
| LBRACE_BAR -> (FSharpTokenColorKind.Punctuation, FSharpTokenCharKind.Delimiter, FSharpTokenTriggerClass.MatchBraces)

| GREATER_RBRACK
| GREATER_BAR_RBRACE
| GREATER_BAR_RBRACK -> (FSharpTokenColorKind.Punctuation, FSharpTokenCharKind.Delimiter, FSharpTokenTriggerClass.None)

| RQUOTE _
Expand Down Expand Up @@ -1387,6 +1388,7 @@ type FSharpTokenKind =
| Comma
| RightArrow
| GreaterBarRightBracket
| GreaterBarRightBrace
| LeftParenthesisStarRightParenthesis
| Open
| Or
Expand Down Expand Up @@ -1598,6 +1600,7 @@ type FSharpToken =
| STAR -> FSharpTokenKind.Star
| COMMA -> FSharpTokenKind.Comma
| RARROW -> FSharpTokenKind.RightArrow
| GREATER_BAR_RBRACE -> FSharpTokenKind.GreaterBarRightBrace
| GREATER_BAR_RBRACK -> FSharpTokenKind.GreaterBarRightBracket
| LPAREN_STAR_RPAREN -> FSharpTokenKind.LeftParenthesisStarRightParenthesis
| OPEN -> FSharpTokenKind.Open
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Service/ServiceLexing.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ type public FSharpTokenKind =
| Comma
| RightArrow
| GreaterBarRightBracket
| GreaterBarRightBrace
| LeftParenthesisStarRightParenthesis
| Open
| Or
Expand Down
7 changes: 6 additions & 1 deletion src/Compiler/SyntaxTree/LexFilter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ type LexFilterImpl (
scanAhead nParen
else
false
| GREATER _ | GREATER_RBRACK | GREATER_BAR_RBRACK ->
| GREATER _ | GREATER_RBRACK | GREATER_BAR_RBRACK | GREATER_BAR_RBRACE ->
let nParen = nParen - 1
let hasAfterOp = (match lookaheadToken with GREATER _ -> false | _ -> true)
if nParen > 0 then
Expand Down Expand Up @@ -1201,6 +1201,11 @@ type LexFilterImpl (
delayToken (pool.UseShiftedLocation(tokenTup, INFIX_AT_HAT_OP "@", 1, 0))
delayToken (pool.UseShiftedLocation(tokenTup, LESS res, 0, -1))
pool.Return tokenTup
| GREATER_BAR_RBRACE ->
lexbuf.CheckLanguageFeatureAndRecover LanguageFeature.BetterAnonymousRecordParsing lexbuf.LexemeRange
delayToken (pool.UseShiftedLocation(tokenTup, BAR_RBRACE, 1, 0))
delayToken (pool.UseShiftedLocation(tokenTup, GREATER res, 0, -2))
pool.Return tokenTup
| GREATER_BAR_RBRACK ->
delayToken (pool.UseShiftedLocation(tokenTup, BAR_RBRACK, 1, 0))
delayToken (pool.UseShiftedLocation(tokenTup, GREATER res, 0, -2))
Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/lex.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,8 @@ rule token (args: LexArgs) (skip: bool) = parse

| ">" { GREATER false }

| ">|}" { GREATER_BAR_RBRACE }

| "[<" { LBRACK_LESS }

| "]" { RBRACK }
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ let parse_error_rich = Some(fun (ctxt: ParseErrorContext<_>) ->
%token EXCEPTION FALSE FOR FUN FUNCTION IF IN JOIN_IN FINALLY DO_BANG
%token LAZY OLAZY MATCH MATCH_BANG MUTABLE NEW OF
%token OPEN OR REC THEN TO TRUE TRY TYPE VAL INLINE INTERFACE INSTANCE CONST
%token WHEN WHILE WHILE_BANG WITH HASH AMP AMP_AMP QUOTE LPAREN RPAREN RPAREN_COMING_SOON RPAREN_IS_HERE STAR COMMA RARROW GREATER_BAR_RBRACK LPAREN_STAR_RPAREN
%token WHEN WHILE WHILE_BANG WITH HASH AMP AMP_AMP QUOTE LPAREN RPAREN RPAREN_COMING_SOON RPAREN_IS_HERE STAR COMMA RARROW GREATER_BAR_RBRACK GREATER_BAR_RBRACE LPAREN_STAR_RPAREN
%token QMARK QMARK_QMARK DOT COLON COLON_COLON COLON_GREATER COLON_QMARK_GREATER COLON_QMARK COLON_EQUALS SEMICOLON
%token SEMICOLON_SEMICOLON LARROW EQUALS LBRACK LBRACK_BAR LBRACE_BAR LBRACK_LESS
%token BAR_RBRACK BAR_RBRACE UNDERSCORE
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSStrings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSStrings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSStrings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading