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

Misplaces = in function signature so it's invalid F# code #1218

Closed
1 of 2 tasks
knocte opened this issue Nov 6, 2020 · 2 comments · Fixed by #1230
Closed
1 of 2 tasks

Misplaces = in function signature so it's invalid F# code #1218

knocte opened this issue Nov 6, 2020 · 2 comments · Fixed by #1230

Comments

@knocte
Copy link
Contributor

knocte commented Nov 6, 2020

Issue created from fantomas-online

Code

module Infrastructure =

    let internal ReportMessage
        (message: string)
#if DEBUG
        (_: ErrorLevel)
#else
        (errorLevel: ErrorLevel)
#endif
        =
#if DEBUG
        failwith message
#else
        let sentryEvent = SentryEvent (SentryMessage message, Level = errorLevel)
        ()
#endif

Error

Fantomas was able to format the code but the result appears to be invalid F# code.
Please open an issue.

Formatted result:

module Infrastructure =

    let internal ReportMessage (message: string)
#if DEBUG
                               (_: ErrorLevel)
#else
                               (errorLevel: ErrorLevel)
#endif
    =
#if DEBUG
        failwith message
#else
        let sentryEvent =
            SentryEvent(SentryMessage message, Level = errorLevel)

        ()
#endif

Expected

Fantomas was able to format the code but the result appears to be invalid F# code.
Please open an issue.

Formatted result:

module Infrastructure =

    let internal ReportMessage (message: string)
#if DEBUG
                               (_: ErrorLevel)
#else
                               (errorLevel: ErrorLevel)
#endif
                               =
#if DEBUG
        failwith message
#else
        let sentryEvent =
            SentryEvent(SentryMessage message, Level = errorLevel)

        ()
#endif

Extra information

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

Options

Fantomas Master at 11/02/2020 11:33:23 - f7b8f3a

Default Fantomas configuration

@knocte knocte changed the title Misplaced = in function signature causes invalid F# code Misplaces = in function signature so it's invalid F# code Nov 6, 2020
@nojaf
Copy link
Contributor

nojaf commented Nov 6, 2020

This might be a more complex problem, I can't really give any pointers on top of my head I'm afraid.

@knocte
Copy link
Contributor Author

knocte commented Nov 6, 2020

This is actually a regression, it was working fine with v4.0.0-alpha-012. I mention this because maybe it's easier to find the bug/fix by bisecting.

knocte added a commit to nblockchain/geewallet that referenced this issue Nov 6, 2020
This version of fantomas doesn't crash anymore when formatting it:
dotnet tool install -g fantomas-tool --add-source https://www.myget.org/F/fantomas/api/v3/index.json --framework netcoreapp3.1 --version 4.0.0-alpha-012

Source will be formatted using this command:
fantomas --recurse src/GWallet.Backend/

Things that would need to be fixed manually before merging this to master:
- We can drop parens in many if statements, e.g.: StratumClient.fs'
CreateVersion's, ServerManager.fs' GetDummyBalanceAction, FTPC.fs'
FTPC type, EtherAccount.fs' GetTransactionCount
- Drop parents in ReadAllText calls of Account.fs
- Many raise lines should use <|, e.g. in WarpKey.fs, UtxoCoinAccount.fs,
and ElectrumServer.fs
- UtxoCoinAccount.fs' EstimateFees unneeded use of |> with 'head'

Fantomas issues from geewallet's wishlist:
- fsprojects/fantomas#712
- fsprojects/fantomas#684
- fsprojects/fantomas#964
- fsprojects/fantomas#1218

Issues not yet reported:
- There should be a setting called AlwaysSplitPipeOperatorInNewLine? but I actually don't understand
the consistency of this:
```
        use webClient = new WebClient()
        let serverListInJson = webClient.DownloadString urlToElectrumJsonFile
        ExtractServerListFromElectrumJsonFile serverListInJson
-           |> Seq.filter FilterCompatibleServer
+       |> Seq.filter FilterCompatibleServer

-    let DefaultBtcList =
-        Caching.Instance.GetServers Currency.BTC
-            |> List.ofSeq
+    let DefaultBtcList = Caching.Instance.GetServers Currency.BTC |> List.ofSeq
```
- MaxLineLength not being respected? look at how long some lines in
UtxoCoinAccount.fs' GetAccountFromFile are.
- UtxoCoinAccount.fs' TransactionOutpoint.ToCoin() should start on next
line.
- Why cut `truncated` var assignment in Formatting.fs'
DecimalAmountTruncating func?
- FaultTolerantParallelClient.fs' Runner.Run is tooooooo long
- Moving comment of FTPC.fs' CustomCancelSource's Dispose func
- This stupid diff adding an unneeded space:
```
             return! faultTolerantEtherClient.Query
                         (FaultTolerantParallelClientDefaultSettings
                             ServerSelectionMode.Fast
-                            currency
-                            (Some (AverageBetweenResponses (minResponsesRequired, AverageGasPrice))))
+                             currency
+                             (Some (AverageBetweenResponses (minResponsesRequired, AverageGasPrice))))
                         web3Funcs
```
- (Investigate) FSharpUtil.option{} that contains a `do! if...`, WAT
- In a lock() statement, it should allow placing the ending `)` in its own
line at the end, in the same column where `lock` starts.

Last but not least, investigate if alpha-012 contains unwanted things like
311bff817f89f8b47c0799eb7474da886175ef15, otherwise we might need to go
back to 04c48d5, which should be
alpha-011 with these fantomas-config.json settings:
{
  "IndentSpaceNum":4,
  "PageWidth":80,
  "SemicolonAtEndOfLine":false,
  "SpaceBeforeParameter":true,
  "SpaceBeforeLowercaseInvocation":true,
  "SpaceBeforeUppercaseInvocation":true,
  "SpaceBeforeClassConstructor":true,
  "SpaceBeforeMember":true,
  "SpaceBeforeColon":false,
  "SpaceAfterComma":true,
  "SpaceBeforeSemicolon":false,
  "SpaceAfterSemicolon":true,
  "IndentOnTryWith":true,
  "SpaceAroundDelimiter":true,
  "MaxIfThenElseShortWidth":0,
  "MaxInfixOperatorExpression":80,
  "MaxRecordWidth":0,
  "MaxFunctionBindingWidth":0,
  "MaxValueBindingWidth":80,
  "MultilineBlockBracketsOnSameColumn":true,
  "NewlineBetweenTypeDefinitionAndMembers":true,
  "KeepIfThenInSameLine":true,
  "StrictMode":false
}
knocte added a commit to nblockchain/geewallet that referenced this issue Nov 6, 2020
dotnet tool install -g fantomas-tool --add-source https://www.myget.org/F/fantomas/api/v3/index.json --framework netcoreapp3.1 --version 4.0.0-beta-001

Things pending to look at in this version:

- crash: reported at fsprojects/fantomas#1218
knocte added a commit to nblockchain/geewallet that referenced this issue Nov 6, 2020
This version of fantomas doesn't crash anymore when formatting it:
dotnet tool install -g fantomas-tool --add-source https://www.myget.org/F/fantomas/api/v3/index.json --framework netcoreapp3.1 --version 4.0.0-alpha-012

Source will be formatted using this command:
fantomas --recurse src/GWallet.Backend/

Things that would need to be fixed manually before merging this to master:
- We can drop parens in many if statements, e.g.: StratumClient.fs'
CreateVersion's, ServerManager.fs' GetDummyBalanceAction, FTPC.fs'
FTPC type, EtherAccount.fs' GetTransactionCount
- Drop parents in ReadAllText calls of Account.fs
- Many raise lines should use <|, e.g. in WarpKey.fs, UtxoCoinAccount.fs,
and ElectrumServer.fs
- UtxoCoinAccount.fs' EstimateFees unneeded use of |> with 'head'

Fantomas issues from geewallet's wishlist:
- fsprojects/fantomas#712
- fsprojects/fantomas#684
- fsprojects/fantomas#964
- fsprojects/fantomas#1218
- fsprojects/fantomas#815 or
fsprojects/fantomas#1221 (but 815 preferred)

Issues not yet reported:
- There should be a setting called AlwaysSplitPipeOperatorInNewLine? but I actually don't understand
the consistency of this:
```
        use webClient = new WebClient()
        let serverListInJson = webClient.DownloadString urlToElectrumJsonFile
        ExtractServerListFromElectrumJsonFile serverListInJson
-           |> Seq.filter FilterCompatibleServer
+       |> Seq.filter FilterCompatibleServer

-    let DefaultBtcList =
-        Caching.Instance.GetServers Currency.BTC
-            |> List.ofSeq
+    let DefaultBtcList = Caching.Instance.GetServers Currency.BTC |> List.ofSeq
```
- MaxLineLength not being respected? look at how long some lines in
UtxoCoinAccount.fs' GetAccountFromFile are.
- UtxoCoinAccount.fs' TransactionOutpoint.ToCoin() should start on next
line.
- Why cut `truncated` var assignment in Formatting.fs'
DecimalAmountTruncating func?
- FaultTolerantParallelClient.fs' Runner.Run is tooooooo long
- Moving comment of FTPC.fs' CustomCancelSource's Dispose func
- This stupid diff adding an unneeded space:
```
             return! faultTolerantEtherClient.Query
                         (FaultTolerantParallelClientDefaultSettings
                             ServerSelectionMode.Fast
-                            currency
-                            (Some (AverageBetweenResponses (minResponsesRequired, AverageGasPrice))))
+                             currency
+                             (Some (AverageBetweenResponses (minResponsesRequired, AverageGasPrice))))
                         web3Funcs
```
- (Investigate) FSharpUtil.option{} that contains a `do! if...`, WAT
- In a lock() statement, it should allow placing the ending `)` in its own
line at the end, in the same column where `lock` starts.

Last but not least, investigate if alpha-012 contains unwanted things like
311bff817f89f8b47c0799eb7474da886175ef15, otherwise we might need to go
back to 04c48d5, which should be
alpha-011 with these fantomas-config.json settings:
{
  "IndentSpaceNum":4,
  "PageWidth":80,
  "SemicolonAtEndOfLine":false,
  "SpaceBeforeParameter":true,
  "SpaceBeforeLowercaseInvocation":true,
  "SpaceBeforeUppercaseInvocation":true,
  "SpaceBeforeClassConstructor":true,
  "SpaceBeforeMember":true,
  "SpaceBeforeColon":false,
  "SpaceAfterComma":true,
  "SpaceBeforeSemicolon":false,
  "SpaceAfterSemicolon":true,
  "IndentOnTryWith":true,
  "SpaceAroundDelimiter":true,
  "MaxIfThenElseShortWidth":0,
  "MaxInfixOperatorExpression":80,
  "MaxRecordWidth":0,
  "MaxFunctionBindingWidth":0,
  "MaxValueBindingWidth":80,
  "MultilineBlockBracketsOnSameColumn":true,
  "NewlineBetweenTypeDefinitionAndMembers":true,
  "KeepIfThenInSameLine":true,
  "StrictMode":false
}
knocte added a commit to nblockchain/geewallet that referenced this issue Nov 6, 2020
dotnet tool install -g fantomas-tool --add-source https://www.myget.org/F/fantomas/api/v3/index.json --framework netcoreapp3.1 --version 4.0.0-beta-001

Things pending to look at in this version:

- crash: reported at fsprojects/fantomas#1218
nojaf added a commit to nojaf/fantomas that referenced this issue Nov 8, 2020
nojaf added a commit that referenced this issue Nov 9, 2020
* WIP

* Refactored LetBindings. Fixes #1218.

* Remove unused leaveEqualsToken.
knocte added a commit to nblockchain/geewallet that referenced this issue Nov 10, 2020
This version of fantomas doesn't crash anymore when formatting it:
dotnet tool install -g fantomas-tool --add-source https://www.myget.org/F/fantomas/api/v3/index.json --framework netcoreapp3.1 --version 4.0.0-alpha-012

Source will be formatted using this command:
fantomas --recurse src/GWallet.Backend/

Things that would need to be fixed manually before merging this to master:
- We can drop parens in many if statements, e.g.: StratumClient.fs'
CreateVersion's, ServerManager.fs' GetDummyBalanceAction, FTPC.fs'
FTPC type, EtherAccount.fs' GetTransactionCount
- Drop parents in ReadAllText calls of Account.fs
- Many raise lines should use <|, e.g. in WarpKey.fs, UtxoCoinAccount.fs,
and ElectrumServer.fs
- UtxoCoinAccount.fs' EstimateFees unneeded use of |> with 'head'

Fantomas issues from geewallet's wishlist:
- fsprojects/fantomas#712
- fsprojects/fantomas#684
- fsprojects/fantomas#964
- fsprojects/fantomas#1218
- In a lock() statement, it should allow placing the ending `)` in its own
line at the end, in the same column where `lock` starts:
 fsprojects/fantomas#815 or
fsprojects/fantomas#1221 (but 815 preferred)
- FaultTolerantParallelClient.fs' Runner.Run is tooooooo long:
fsprojects/fantomas#1133
- Moving comment of FTPC.fs' CustomCancelSource's Dispose func:
fsprojects/fantomas#1233

Issues not yet reported:
- There should be a setting called AlwaysSplitPipeOperatorToNewLine?
- MaxLineLength not being respected? look at how long some lines in
UtxoCoinAccount.fs' GetAccountFromFile are.
- UtxoCoinAccount.fs' TransactionOutpoint.ToCoin() should start on next
line.
- This stupid diff adding an unneeded space:
```
             return! faultTolerantEtherClient.Query
                         (FaultTolerantParallelClientDefaultSettings
                             ServerSelectionMode.Fast
-                            currency
-                            (Some (AverageBetweenResponses (minResponsesRequired, AverageGasPrice))))
+                             currency
+                             (Some (AverageBetweenResponses (minResponsesRequired, AverageGasPrice))))
                         web3Funcs
```
- (Investigate) FSharpUtil.option{} that contains a `do! if...`, WAT

Last but not least, investigate if alpha-012 contains unwanted things like
311bff817f89f8b47c0799eb7474da886175ef15, otherwise we might need to go
back to 04c48d5, which should be
alpha-011 with these fantomas-config.json settings:
{
  "IndentSpaceNum":4,
  "PageWidth":80,
  "SemicolonAtEndOfLine":false,
  "SpaceBeforeParameter":true,
  "SpaceBeforeLowercaseInvocation":true,
  "SpaceBeforeUppercaseInvocation":true,
  "SpaceBeforeClassConstructor":true,
  "SpaceBeforeMember":true,
  "SpaceBeforeColon":false,
  "SpaceAfterComma":true,
  "SpaceBeforeSemicolon":false,
  "SpaceAfterSemicolon":true,
  "IndentOnTryWith":true,
  "SpaceAroundDelimiter":true,
  "MaxIfThenElseShortWidth":0,
  "MaxInfixOperatorExpression":80,
  "MaxRecordWidth":0,
  "MaxFunctionBindingWidth":0,
  "MaxValueBindingWidth":80,
  "MultilineBlockBracketsOnSameColumn":true,
  "NewlineBetweenTypeDefinitionAndMembers":true,
  "KeepIfThenInSameLine":true,
  "StrictMode":false
}
knocte added a commit to nblockchain/geewallet that referenced this issue Nov 10, 2020
This version of fantomas doesn't crash anymore when formatting it:
dotnet tool install -g fantomas-tool --add-source https://www.myget.org/F/fantomas/api/v3/index.json --framework netcoreapp3.1 --version 4.0.0-alpha-012

Source will be formatted using this command:
fantomas --recurse src/GWallet.Backend/

Things that would need to be fixed manually before merging this to master:
- We can drop parens in many if statements, e.g.: StratumClient.fs'
CreateVersion's, ServerManager.fs' GetDummyBalanceAction, FTPC.fs'
FTPC type, EtherAccount.fs' GetTransactionCount
- Drop parents in ReadAllText calls of Account.fs
- Many raise lines should use <|, e.g. in WarpKey.fs, UtxoCoinAccount.fs,
and ElectrumServer.fs
- UtxoCoinAccount.fs' EstimateFees unneeded use of |> with 'head'

Fantomas issues from geewallet's wishlist:
- fsprojects/fantomas#712
- fsprojects/fantomas#684
- fsprojects/fantomas#964
- fsprojects/fantomas#1235
- fsprojects/fantomas#1218
- In a lock() statement, it should allow placing the ending `)` in its own
line at the end, in the same column where `lock` starts:
 fsprojects/fantomas#815 or
fsprojects/fantomas#1221 (but 815 preferred)
- FaultTolerantParallelClient.fs' Runner.Run is tooooooo long:
fsprojects/fantomas#1133
- Moving comment of FTPC.fs' CustomCancelSource's Dispose func:
fsprojects/fantomas#1233

Issues not yet reported:
- There should be a setting called AlwaysSplitPipeOperatorToNewLine?
- MaxLineLength not being respected? look at how long some lines in
UtxoCoinAccount.fs' GetAccountFromFile are.
- UtxoCoinAccount.fs' TransactionOutpoint.ToCoin() should start on next
line -> fixed in v.NEXT
- This stupid diff adding an unneeded space:
```
             return! faultTolerantEtherClient.Query
                         (FaultTolerantParallelClientDefaultSettings
                             ServerSelectionMode.Fast
-                            currency
-                            (Some (AverageBetweenResponses (minResponsesRequired, AverageGasPrice))))
+                             currency
+                             (Some (AverageBetweenResponses (minResponsesRequired, AverageGasPrice))))
                         web3Funcs
```
(seems to be fixed in v.NEXT)
- (Investigate) FSharpUtil.option{} that contains a `do! if...`, WAT

Last but not least, investigate if alpha-012 contains unwanted things like
311bff817f89f8b47c0799eb7474da886175ef15, otherwise we might need to go
back to 04c48d5, which should be
alpha-011 with these fantomas-config.json settings:
{
  "IndentSpaceNum":4,
  "PageWidth":80,
  "SemicolonAtEndOfLine":false,
  "SpaceBeforeParameter":true,
  "SpaceBeforeLowercaseInvocation":true,
  "SpaceBeforeUppercaseInvocation":true,
  "SpaceBeforeClassConstructor":true,
  "SpaceBeforeMember":true,
  "SpaceBeforeColon":false,
  "SpaceAfterComma":true,
  "SpaceBeforeSemicolon":false,
  "SpaceAfterSemicolon":true,
  "IndentOnTryWith":true,
  "SpaceAroundDelimiter":true,
  "MaxIfThenElseShortWidth":0,
  "MaxInfixOperatorExpression":80,
  "MaxRecordWidth":0,
  "MaxFunctionBindingWidth":0,
  "MaxValueBindingWidth":80,
  "MultilineBlockBracketsOnSameColumn":true,
  "NewlineBetweenTypeDefinitionAndMembers":true,
  "KeepIfThenInSameLine":true,
  "StrictMode":false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants