Allow closing '>' of multiline nested type arguments to align with th… · dotnet/fsharp@34a3053 · GitHub
Skip to content

Commit 34a3053

Browse files
authored
Allow closing '>' of multiline nested type arguments to align with the opener (#15171) (#20003)
1 parent e1ad05c commit 34a3053

6 files changed

Lines changed: 91 additions & 1 deletion

File tree

‎docs/release-notes/.FSharp.Compiler.Service/11.0.100.md‎

Lines changed: 1 addition & 0 deletions

‎src/Compiler/SyntaxTree/LexFilter.fs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ let rec isSeqBlockElementContinuator token =
383383
// Shortcut.CtrlO)
384384
| END | AND | WITH | THEN | RPAREN | RBRACE _ | BAR_RBRACE | RBRACK | BAR_RBRACK | RQUOTE _ -> true
385385

386+
// A closing '>' of a (possibly multiline) type-argument list is a closing bracket, like ')' or ']'
387+
// above: it may align with the first column of a sequence block without starting a new element.
388+
// See dotnet/fsharp#15171.
389+
| GREATER true -> true
390+
386391
// The following arise during reprocessing of the inserted tokens when we hit a DONE
387392
| ORIGHT_BLOCK_END _ | OBLOCKEND _ | ODECLEND (_, _) -> true
388393
| ODUMMY token -> isSeqBlockElementContinuator token
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// #Regression #Conformance #LexFilter #Exceptions
2+
// https://github.com/dotnet/fsharp/issues/15171
3+
// The closing '>' of a nested, multiline type-argument list may align with the column of the
4+
// opening type name (here the inner 'Foo'); it must not be treated as a new sequence-block item.
5+
6+
open System
7+
8+
type Bar = class end
9+
type Foo<'a> = class end
10+
11+
type Terminal =
12+
abstract onKey:
13+
IEvent<
14+
Foo<
15+
Bar * int
16+
>
17+
> with get, set

‎tests/FSharp.Compiler.ComponentTests/Conformance/LexicalFiltering/OffsideExceptions/OffsideExceptions.fs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ open FSharp.Test.Compiler.Assertions.StructuredResultsAsserts
99

1010
module OffsideExceptions =
1111

12+
// https://github.com/dotnet/fsharp/issues/15171
13+
// The closing '>' of a nested multiline type-argument list may align with the opening type name.
14+
[<Theory; FileInlineData("MultilineNestedTypeArguments.fs")>]
15+
let MultilineNestedTypeArguments compilation =
16+
compilation
17+
|> getCompilation
18+
|> asFsx
19+
|> typecheck
20+
|> shouldSucceed
21+
|> ignore
22+
1223
// This test was automatically generated (moved from FSharpQA suite - Conformance/LexicalFiltering/Basic/OffsideExceptions)
1324
//<Expects status="success"></Expects>
1425
[<Theory; FileInlineData("InfixTokenPlusOne.fs")>]
1526
let InfixTokenPlusOne compilation =
1627
compilation
17-
|> getCompilation
28+
|> getCompilation
1829
|> asFsx
1930
|> typecheck
2031
|> shouldSucceed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type T =
2+
abstract M:
3+
A<
4+
B<
5+
int
6+
>
7+
>
Lines changed: 49 additions & 0 deletions

0 commit comments

Comments
 (0)