fantomas icon indicating copy to clipboard operation
fantomas copied to clipboard

Compiler define in match clause

Open nojaf opened this issue 4 years ago • 0 comments

Issue created from fantomas-online

Code

try 
    match synTyconRepr with 
    | SynTypeDefnSimpleRepr.TypeAbbrev(ParserDetail.Ok, rhsType, m) ->
#if !NO_EXTENSIONTYPING
        if (match tycon.entity_tycon_repr with TNoRepr -> true | _ -> false) then 
        match TcTyconDefnCore_TryAsGenerateDeclaration cenv envinner tpenv (tycon, rhsType) with 
        | None -> 
#else
            ignore inSig 
#endif
            if not hasMeasureableAttr then 
            if not firstPass then 
                if ftyvs.Length <> typars.Length then 
                    errorR(Deprecated(FSComp.SR.tcTypeAbbreviationHasTypeParametersMissingOnType(), tycon.Range))

            if firstPass then
                tycon.SetTypeAbbrev (Some ty)
    | _ -> ()
with e -> 
    errorRecovery e m

Error

Fantomas.FormatConfig+FormatException: Parsing failed with errors: [|tmp.fsx (13,17)-(13,19) parse error Unexpected keyword 'if' in expression. Expected incomplete structured construct at or before this point or other token.|]
And options: { SourceFiles = [|"tmp.fsx"|]
  ConditionalCompilationDefines = ["NO_EXTENSIONTYPING"]
  ErrorSeverityOptions = { WarnLevel = 3
                           GlobalWarnAsError = false
                           WarnOff = []
                           WarnOn = []
                           WarnAsError = []
                           WarnAsWarn = [] }
  IsInteractive = false
  LightSyntax = None
  CompilingFsLib = false
  IsExe = false }
   at [email protected](FSharpParseFileResults _arg2) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodeFormatterImpl.fs:line 81
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, FSharpFunc`2 userCode, b result1) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 404
   at <StartupCode$FSharp-Compiler-Service>[email protected](AsyncActivation`1 ctxt) in D:\workspace\_work\1\s\src\fsharp\service\service.fs:line 457
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104

Problem description

Not sure what's up, looks like fun...

Extra information

  • [x] 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 04/04/2021 08:26:51 - abb31287ff651e2d58491695fc19e7545b1dae38

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?

nojaf avatar Apr 04 '21 09:04 nojaf