diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c6e43a44..2ea411c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - `///` doc comment without associated declaration (e.g. at end of file) was duplicated when formatting. [#2499](https://github.com/fsprojects/fantomas/issues/2499) - NamedIndexedPropertySet with two SynLongIdent removed space. [#3273](https://github.com/fsprojects/fantomas/issues/3273) - `%%` (double-percent) infix operator moved to new line, producing invalid F#. [#2107](https://github.com/fsprojects/fantomas/issues/2107) +- Indentation warning when formatting `match` with long anonymous record discriminant. [#1903](https://github.com/fsprojects/fantomas/issues/1903) ## [8.0.0-alpha-007] - 2026-03-10 diff --git a/src/Fantomas.Core.Tests/PatternMatchingTests.fs b/src/Fantomas.Core.Tests/PatternMatchingTests.fs index edbb66303..9eb0f9c5b 100644 --- a/src/Fantomas.Core.Tests/PatternMatchingTests.fs +++ b/src/Fantomas.Core.Tests/PatternMatchingTests.fs @@ -2339,3 +2339,59 @@ let v, x = & Assumenda assumenda -> libero, [] | _ -> saepe, delectus """ + +[] +let ``match on long anonymous record type discriminant does not cause indentation warning, 1903`` () = + let config60 = { config with MaxLineLength = 60 } + + formatSourceString + """ +match + (unbox<{| __proto__: {| ChooseAsync: (('T -> Async<_ option>) -> AsyncSeq<_>) option |} option |}> ( + source' + )) + .__proto__ with +| Some proto when proto.ChooseAsync.IsSome -> + source'.ChooseAsync f +| _ -> + asyncSeq { + for itm in source do + let! v = f itm + + match v with + | Some v -> yield v + | _ -> () + } +""" + config60 + |> prepend newline + |> should + equal + """ +match + (unbox< + {| + __proto__: + {| + ChooseAsync: + (('T -> Async<_ option>) + -> AsyncSeq<_>) option + |} option + |} + > ( + source' + )) + .__proto__ +with +| Some proto when proto.ChooseAsync.IsSome -> + source'.ChooseAsync f +| _ -> + asyncSeq { + for itm in source do + let! v = f itm + + match v with + | Some v -> yield v + | _ -> () + } +"""