From 26559432860acd7cc69ef282945cfd758f9f3af0 Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 26 Feb 2026 14:10:30 +0100 Subject: [PATCH] Add regression test for issue 2844: trivia around paren lambda with conditional compilation --- CHANGELOG.md | 1 + .../CompilerDirectivesTests.fs | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 599a16e66..b09e66113 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed - End of line comments after infix operators are preserved correctly. [#2287](https://github.com/fsprojects/fantomas/issues/2287) +- Trivia around paren lambda with conditional compilation no longer causes merge error. [#2844](https://github.com/fsprojects/fantomas/issues/2844) ## [8.0.0-alpha-002] - 2025-12-15 diff --git a/src/Fantomas.Core.Tests/CompilerDirectivesTests.fs b/src/Fantomas.Core.Tests/CompilerDirectivesTests.fs index 34aa3ebb2..b35c44466 100644 --- a/src/Fantomas.Core.Tests/CompilerDirectivesTests.fs +++ b/src/Fantomas.Core.Tests/CompilerDirectivesTests.fs @@ -3240,3 +3240,46 @@ let CombineImportedAssembliesTask () """ + +[] +let ``trivia around paren lambda with conditional compilation, 2844`` () = + formatSourceString + """ +Program.statefulWithCmdMsg +|> (fun program -> + { program with + CanReuseView = ViewHelper.canReuseView + SyncAction = + (fun fn -> + program.SyncAction + ( +#if IOS + // iOS animates by default layout changes, we don't want that + fun () -> UIKit.UIView.PerformWithoutAnimation(fn) +#else + fn +#endif + )) }) +""" + config + |> prepend newline + |> should + equal + """ +Program.statefulWithCmdMsg +|> (fun program -> + { program with + CanReuseView = ViewHelper.canReuseView + SyncAction = + (fun fn -> + program.SyncAction + ( +#if IOS + // iOS animates by default layout changes, we don't want that + fun () -> UIKit.UIView.PerformWithoutAnimation(fn) +#else + fn +#endif + )) + }) +"""