Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trivia around paren lambda not restore #2844

Open
1 of 3 tasks
edgarfgp opened this issue Apr 14, 2023 · 2 comments
Open
1 of 3 tasks

Trivia around paren lambda not restore #2844

edgarfgp opened this issue Apr 14, 2023 · 2 comments

Comments

@edgarfgp
Copy link
Contributor

Issue created from fantomas-online

Code

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
                        )) })

Error

System.FormatException: Fantomas is trying to format the input multiple times due to the detection of multiple defines.
There is a problem with merging all the code back together.
[] has 7 fragments
[IOS] has 9 fragments
Please raise an issue at https://fsprojects.github.io/fantomas-tools/#/fantomas/preview.
   at Fantomas.Core.MultipleDefineCombinations.mergeMultipleFormatResults(FormatConfig config, FSharpList`1 results) in /_//src/Fantomas.Core/MultipleDefineCombinations.fs:line 209
   at Fantomas.Core.CodeFormatterImpl.formatDocument@95-5.Invoke(FSharpList`1 results) in /_//src/Fantomas.Core/CodeFormatterImpl.fs:line 99
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, b result1, FSharpFunc`2 userCode) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 525
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112

Problem description

Please describe here the Fantomas problem you encountered.
Check out our Contribution Guidelines.

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas main branch at 2023-04-14T07:44:28Z - dfc29ff

Default Fantomas configuration

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

@edgarfgp edgarfgp changed the title Unable to format the follwing snippet Unable to format the following snippet Apr 14, 2023
@nojaf
Copy link
Contributor

nojaf commented Apr 14, 2023

Hi Edgar,

Thank you for reporting this issue.
I'm going to write some documentation on how you can solve this problem.
There is a way to pinpoint where the problem exactly lies.

Also, please try and make your sample as small as possible.

You will probably need to remove |> genNode lambdaNode in

+> (genLambdaWithParen lambdaNode |> genNode lambdaNode)

But this will make more sense once the docs are there.

@nojaf
Copy link
Contributor

nojaf commented Apr 14, 2023

@nojaf nojaf changed the title Unable to format the following snippet Trivia around paren lambda not restore Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants