Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions src/Compiler/SyntaxTree/LexFilter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,3 +673,73 @@ let nested2 : {| A: {| B: Expr<int> |}; 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
[<Fact>]
let ``Anonymous record type alias with array suffix - closing bracket aligned with opening``() =
FSharp """
module M
type T =
{| Id: System.Guid
|} []
"""
|> typecheck
|> shouldSucceed

[<Fact>]
let ``Anonymous record type alias with seq postfix - closing bracket aligned with opening``() =
FSharp """
module M
type T =
{| Id: System.Guid
|} seq
"""
|> typecheck
|> shouldSucceed

[<Fact>]
let ``Anonymous record type alias with list postfix - closing bracket aligned with opening``() =
FSharp """
module M
type T =
{| Id: System.Guid
|} list
"""
|> typecheck
|> shouldSucceed

[<Fact>]
let ``Anonymous record type alias with option postfix - closing bracket aligned with opening``() =
FSharp """
module M
type T =
{| Id: System.Guid
|} option
"""
|> typecheck
|> shouldSucceed

[<Fact>]
let ``Anonymous record type alias with multiple fields and array suffix``() =
FSharp """
module M
type T =
{| Id: System.Guid
Name: string
|} []
"""
|> typecheck
|> shouldSucceed

[<Fact>]
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
Loading