Skip to content
Merged
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
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ All scripts accept a file path or stdin, with optional `--signature` and `--edit

Scripts require a debug build first (`dotnet build src/Fantomas/Fantomas.fsproj`).

## Changelog

When updating `CHANGELOG.md`, add new entries to the **end** of the relevant section (e.g. `### Fixed`), not the top. One entry per issue.

## Post-task Steps

Run these after completing a task, not during iterative development — analyzers can be slow.
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## [Unreleased]
## [8.0.0-alpha-008] - 2026-03-25

### Added

Expand All @@ -14,6 +14,9 @@
- `%%` (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)
- Index-without-dot with variable key followed by unit arguments added spurious spaces, e.g. `dict[key] () ()` became `dict [ key ] () ()`. [#2519](https://github.com/fsprojects/fantomas/issues/2519)
- Open-ended expressions (lambda, if-then-else, match, ...) in non-last positions of infix, tuple, list/array, and record expressions now stay multiline to preserve semantics. [#3279](https://github.com/fsprojects/fantomas/issues/3279)
- Lambda in tuple in list on single line changes code meaning. [#3278](https://github.com/fsprojects/fantomas/issues/3278)
- Custom operator applied to lambda collapses to single line changing semantics. [#3274](https://github.com/fsprojects/fantomas/issues/3274)

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

Expand Down
5 changes: 3 additions & 2 deletions src/Fantomas.Core.Tests/ControlStructureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ elif true then ()
"""

[<Test>]
let ``multiline if in tuple`` () =
let ``multiline if in tuple uses comma-leading layout`` () =
formatSourceString
"""
(if true then 1 else 2
Expand All @@ -428,7 +428,8 @@ let ``multiline if in tuple`` () =
|> should
equal
"""
((if true then 1 else 2), 3)
(if true then 1 else 2
, 3)
"""

// https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/formatting#formatting-if-expressions
Expand Down
1 change: 1 addition & 0 deletions src/Fantomas.Core.Tests/Fantomas.Core.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
<Compile Include="NullnessTests.fs" />
<Compile Include="AutoPropertiesTests.fs" />
<Compile Include="PrefixTests.fs" />
<Compile Include="RequiresMultilineToPreserveSemanticsTests.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Fantomas.Core\Fantomas.Core.fsproj" />
Expand Down
15 changes: 11 additions & 4 deletions src/Fantomas.Core.Tests/LambdaTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ let dayOfWeekToNum (d: DayOfWeek) =
"""

[<Test>]
let ``piped lambda with if-then-else, short, 2196`` () =
let ``piped lambda with if-then-else stays multiline to preserve semantics, 2196`` () =
formatSourceString
"""
let foo () =
Expand All @@ -1187,7 +1187,9 @@ let foo () =
equal
"""
let foo () =
f () |> (fun x -> if x then 1 else 2) |> g
f ()
|> fun x -> if x then 1 else 2
|> g
"""

[<Test>]
Expand Down Expand Up @@ -1457,7 +1459,7 @@ f
"""

[<Test>]
let ``lambda in non-last record field should be parenthesized on single line, 3246`` () =
let ``lambda in non-last record field stays multiline to preserve semantics, 3246`` () =
formatSourceString
"""
type Rec = {
Expand All @@ -1480,5 +1482,10 @@ let test () : Rec =
"""
type Rec = { A: int; B: int -> int; C: int }

let test () : Rec = { A = 1; B = (fun x -> x + 1); C = 3 }
let test () : Rec =
{
A = 1
B = fun x -> x + 1
C = 3
}
"""
19 changes: 13 additions & 6 deletions src/Fantomas.Core.Tests/OperatorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ let ( */ ) = (+)
"""

[<Test>]
let ``piped lambda on a single line`` () =
let ``piped lambda stays multiline to preserve semantics`` () =
formatSourceString
"""
let a : (unit -> int) list =
Expand All @@ -1268,11 +1268,14 @@ let a : (unit -> int) list =
|> should
equal
"""
let a: (unit -> int) list = (fun () -> failwith "": int) |> List.singleton |> id
let a: (unit -> int) list =
fun () -> failwith "": int
|> List.singleton
|> id
"""

[<Test>]
let ``piped tuple on a single line`` () =
let ``piped tuple stays multiline to preserve semantics`` () =
formatSourceString
"""
fun i -> sprintf "%i" i, fun () -> i
Expand All @@ -1284,11 +1287,13 @@ fun i -> sprintf "%i" i, fun () -> i
|> should
equal
"""
(fun i -> sprintf "%i" i, fun () -> i) |> List.init foo |> Map.ofList
fun i -> sprintf "%i" i, fun () -> i
|> List.init foo
|> Map.ofList
"""

[<Test>]
let ``lambda piped into non newlineInfixApp`` () =
let ``lambda piped into non newlineInfixApp stays multiline to preserve semantics`` () =
formatSourceString
"""
fun sum count -> sum / float count
Expand All @@ -1300,7 +1305,9 @@ fun sum count -> sum / float count
|> should
equal
"""
(fun sum count -> sum / float count) <*| sum xs <*| count
fun sum count -> sum / float count
<*| sum xs
<*| count
"""

[<Test>]
Expand Down
Loading
Loading