Skip to content

Commit 82f5bab

Browse files
authored
Merge pull request #3296 from fsprojects/repo-assist/regression-test-1903-match-anon-record-indentation-044a592e512dc5ef
[Repo Assist] Add regression test for match on long anonymous record discriminant, 1903
2 parents 4f1fafb + 129575c commit 82f5bab

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- `///` doc comment without associated declaration (e.g. at end of file) was duplicated when formatting. [#2499](https://github.com/fsprojects/fantomas/issues/2499)
1313
- NamedIndexedPropertySet with two SynLongIdent removed space. [#3273](https://github.com/fsprojects/fantomas/issues/3273)
1414
- `%%` (double-percent) infix operator moved to new line, producing invalid F#. [#2107](https://github.com/fsprojects/fantomas/issues/2107)
15+
- Indentation warning when formatting `match` with long anonymous record discriminant. [#1903](https://github.com/fsprojects/fantomas/issues/1903)
1516

1617
## [8.0.0-alpha-007] - 2026-03-10
1718

src/Fantomas.Core.Tests/PatternMatchingTests.fs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,3 +2339,59 @@ let v, x =
23392339
& Assumenda assumenda -> libero, []
23402340
| _ -> saepe, delectus
23412341
"""
2342+
2343+
[<Test>]
2344+
let ``match on long anonymous record type discriminant does not cause indentation warning, 1903`` () =
2345+
let config60 = { config with MaxLineLength = 60 }
2346+
2347+
formatSourceString
2348+
"""
2349+
match
2350+
(unbox<{| __proto__: {| ChooseAsync: (('T -> Async<_ option>) -> AsyncSeq<_>) option |} option |}> (
2351+
source'
2352+
))
2353+
.__proto__ with
2354+
| Some proto when proto.ChooseAsync.IsSome ->
2355+
source'.ChooseAsync f
2356+
| _ ->
2357+
asyncSeq {
2358+
for itm in source do
2359+
let! v = f itm
2360+
2361+
match v with
2362+
| Some v -> yield v
2363+
| _ -> ()
2364+
}
2365+
"""
2366+
config60
2367+
|> prepend newline
2368+
|> should
2369+
equal
2370+
"""
2371+
match
2372+
(unbox<
2373+
{|
2374+
__proto__:
2375+
{|
2376+
ChooseAsync:
2377+
(('T -> Async<_ option>)
2378+
-> AsyncSeq<_>) option
2379+
|} option
2380+
|}
2381+
> (
2382+
source'
2383+
))
2384+
.__proto__
2385+
with
2386+
| Some proto when proto.ChooseAsync.IsSome ->
2387+
source'.ChooseAsync f
2388+
| _ ->
2389+
asyncSeq {
2390+
for itm in source do
2391+
let! v = f itm
2392+
2393+
match v with
2394+
| Some v -> yield v
2395+
| _ -> ()
2396+
}
2397+
"""

0 commit comments

Comments
 (0)