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

FormatException: Unexpected symbol '|' for DU case under pre-processor directive #1483

Closed
3 tasks
theimowski opened this issue Feb 26, 2021 · 0 comments · Fixed by #1592
Closed
3 tasks

FormatException: Unexpected symbol '|' for DU case under pre-processor directive #1483

theimowski opened this issue Feb 26, 2021 · 0 comments · Fixed by #1592

Comments

@theimowski
Copy link
Member

Issue created from fantomas-online

Code

type A =
    | B
#if DEBUG
    | C
#endif

Error

Fantomas.FormatConfig+FormatException: Parsing failed with errors: [|tmp.fsx (3,5)-(3,6) parse error Unexpected symbol '|' in implementation file|]
And options: { SourceFiles = [|"tmp.fsx"|]
  ConditionalCompilationDefines = ["DEBUG"]
  ErrorSeverityOptions = { WarnLevel = 3
                           GlobalWarnAsError = false
                           WarnOff = []
                           WarnOn = []
                           WarnAsError = []
                           WarnAsWarn = [] }
  IsInteractive = false
  LightSyntax = None
  CompilingFsLib = false
  IsExe = false }
   at Fantomas.CodeFormatterImpl.parse@76-2.Invoke(FSharpParseFileResults _arg2) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodeFormatterImpl.fs:line 82
   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>.$Service.ParseFile@457-3.Invoke(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

When using conditional compilation with pre-processor directives, error occurs for a DU with case that is under that condition

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 02/26/2021 10:32:56 - 6464684

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?

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