Closed zakaluka closed 4 years ago
1) I can confirm this, @zakaluka please create seperate issue with this snippet. It doesn't happen for each CE, my guess is it is connected to multiline expr as first thing in CE.
2) Also confirmed. It can be reproduced wtih this FAKE5 script:
#r "paket: nuget Fantomas"
#load ".fake/test-FAKE5.fsx/intellisense.fsx"
let mkTempFile source =
let fileName = System.IO.Path.GetTempFileName() + ".fs"
System.IO.File.WriteAllText(fileName, source)
fileName
let source = "let getInitCounter() : Task<Counter> = task { return 42 }"
let path = mkTempFile source
Fantomas.CodeFormatter.FormatDocument(path, System.IO.File.ReadAllText(path), Fantomas.FormatConfig.FormatConfig.Default)
System.IO.File.Delete path
It's weird because with CLI this code will be formatted without problem.
While working on http://ratatosk.dynu.net/fantomas/, I encounter second issue. Turns out it is caused by different versions of FSharp.Compiler.Service
. Fantomas use 23.0.3, but when you use Fantomas as lib dependency, newer one is used (25.0.1) and it cause these issues.
Workaround is to use matching version of FSharp.Compiler.Service
, this header of above script works:
#r "paket: nuget Fantomas
nuget FSharp.Compiler.Service 23.0.3"
Another option is to use
#r "paket: strategy: min
nuget Fantomas"
I think we have two options how to fix this:
1) upgrade FSharp.Compiler.Service
to 25.0.1. That will force everyone who is using Fantomas as lib to also upgrade. Not sure if that is OK.
2) change FSharp.Compiler.Service
dependency in nuget to be exactly 23.0.3 (now is >=23.0.3). That would probably needs to change way of how we are creating nuget package, I wasn't able to find a way how to do it by dotnet pack
parameter. It should be doable with paket pack
.
I would prefer option 1.
I have created a separate issue #339 to deal with the second issue presented above (YieldOrReturn
to YieldOrReturnFrom
).
Hello,
I am trying the latest Fantomas on the default SAFE stack template, using Saturn. For the most part, it is formatting the code well. However, Saturn uses a number of custom computation expressions, and Fantomas is behaving very oddly.
I am seeing 2 issues.
First question has to do with how the following code block is reformatted. By default,
Server.fs
contains the following block of code:I ran the file through the Fantomas command-line utility (no options), and it changed to the following:
While I understand some of the behavior, I don't understand why
router
and{
are on separate lines. From looking at the computation expression tests https://github.com/fsprojects/fantomas/blob/master/src/Fantomas.Tests/ComputationExpressionTests.fs, it should have looked likerouter {
.On a positive note, it didn't indent the
get
call any further.PLEASE SEE #339 FOR MORE INFORMATION ABOUT THE FOLLOWING ISSUE. Second question is about when I format through the Fantomas library and FAKE. I am seeing the following error message when I try to run the
Server.fs
file throughcheckCode
.If I comment out all the computation expressions in
Server.fs
, then that error goes away. However, any computation express inServer.fs
causes the error to be printed out. Because of this, I'm concerned about runningServer.fs
throughformatCode
.I even tried leaving only one computation expression
Server.fs
:Based on what I saw in Fantomas, this is a
YieldOrReturn
. I still get the same error message. Why is Fantomas trying to change this toYieldOrReturnFrom
(akareturn!
)?