From 62efdad26fece7a57b801ff044e90e0e0ccd0d68 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 11:23:09 +0000 Subject: [PATCH 1/3] Initial plan From 1d471e8d1ae2bd1122f0c08e340b413c2dfc629c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 12:30:00 +0000 Subject: [PATCH 2/3] Fix anonymous record type alias with array/generic type suffix error when closing bracket is aligned with opening bracket Add BAR_RBRACE to isTypeSeqBlockElementContinuator in LexFilter.fs to prevent incorrect OBLOCKSEP insertion after closing |} in type alias contexts. This fixes the error 'Unexpected symbol [' in member definition' when writing: type T = {| Id: Guid |} [] // or |} seq, |} list, |} option Add tests covering the fixed cases in AnonymousRecords.fs. Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/efa54b78-f657-43e6-a50e-05db045cba9d Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com> --- src/Compiler/SyntaxTree/LexFilter.fs | 8 +++ .../Types/RecordTypes/AnonymousRecords.fs | 70 +++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/src/Compiler/SyntaxTree/LexFilter.fs b/src/Compiler/SyntaxTree/LexFilter.fs index ed5da9fd043..e0e450c398f 100644 --- a/src/Compiler/SyntaxTree/LexFilter.fs +++ b/src/Compiler/SyntaxTree/LexFilter.fs @@ -352,6 +352,14 @@ let rec isTypeSeqBlockElementContinuator token = // member x.M1 // member x.M2 | BAR -> true + // Closing tokens for anonymous record types and struct types in type aliases, e.g. + // type T = + // {| Id: int + // |} [] <-- BAR_RBRACE here should not trigger OBLOCKSEP for '[]' + // type T = + // {| Id: int + // |} seq <-- BAR_RBRACE here should not trigger OBLOCKSEP for 'seq' + | BAR_RBRACE -> true | OBLOCKBEGIN | ORIGHT_BLOCK_END _ | OBLOCKEND _ | ODECLEND (_, _) -> true // The following arise during reprocessing of the inserted tokens when we hit a DONE | ODUMMY token -> isTypeSeqBlockElementContinuator token | _ -> false diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs index 69c14a8d418..beef862b27a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Types/RecordTypes/AnonymousRecords.fs @@ -673,3 +673,73 @@ let nested2 : {| A: {| B: Expr |}; C: Expr |} = (Error 3350, Line 8, Col 22, Line 8, Col 24, "Feature 'Support for better anonymous record parsing' is not available in F# 9.0. Please use language version 10.0 or greater.") (Error 3350, Line 8, Col 44, Line 8, Col 49, "Feature 'Support for better anonymous record parsing' is not available in F# 9.0. Please use language version 10.0 or greater.") ] + +module TypeAliasIndentation = + + // https://github.com/dotnet/fsharp/issues/17992 + [] + let ``Anonymous record type alias with array suffix - closing bracket aligned with opening``() = + FSharp """ +module M +type T = + {| Id: System.Guid + |} [] +""" + |> typecheck + |> shouldSucceed + + [] + let ``Anonymous record type alias with seq postfix - closing bracket aligned with opening``() = + FSharp """ +module M +type T = + {| Id: System.Guid + |} seq +""" + |> typecheck + |> shouldSucceed + + [] + let ``Anonymous record type alias with list postfix - closing bracket aligned with opening``() = + FSharp """ +module M +type T = + {| Id: System.Guid + |} list +""" + |> typecheck + |> shouldSucceed + + [] + let ``Anonymous record type alias with option postfix - closing bracket aligned with opening``() = + FSharp """ +module M +type T = + {| Id: System.Guid + |} option +""" + |> typecheck + |> shouldSucceed + + [] + let ``Anonymous record type alias with multiple fields and array suffix``() = + FSharp """ +module M +type T = + {| Id: System.Guid + Name: string + |} [] +""" + |> typecheck + |> shouldSucceed + + [] + let ``Anonymous record type alias all on same line still works``() = + FSharp """ +module M +type T = {| Id: System.Guid |} [] +type U = {| Id: System.Guid |} seq +type V = {| Id: System.Guid |} list +""" + |> typecheck + |> shouldSucceed From 175a852fb00cc74e0086b98853b0249a850edf24 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Mon, 25 May 2026 14:01:04 +0200 Subject: [PATCH 3/3] Add release notes for anonymous record type alias parser fix Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/release-notes/.FSharp.Compiler.Service/11.0.100.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md index 4a6110cf514..6259a6804ba 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -54,6 +54,7 @@ * Fix parallel compilation of scripts ([PR #19649](https://github.com/dotnet/fsharp/pull/19649)) * Fix parser recovery, name resolution, and code completion for unfinished enum patterns ([PR #19708](https://github.com/dotnet/fsharp/pull/19708)) * Parser: fix unexpected diagnostics in debug builds, improve error messages ([PR #19730](https://github.com/dotnet/fsharp/pull/19730)) +* Fix parser error for anonymous record type aliases with postfix type operators (e.g. `{| Id: Guid |} []`) when closing bracket is column-aligned with opening bracket. ([Issue #17407](https://github.com/dotnet/fsharp/issues/17407), [PR #19762](https://github.com/dotnet/fsharp/pull/19762)) ### Added