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

Exception with boolean constant in #if #2013

Closed
1 of 3 tasks
jindraivanek opened this issue Jan 8, 2022 · 0 comments · Fixed by #2019
Closed
1 of 3 tasks

Exception with boolean constant in #if #2013

jindraivanek opened this issue Jan 8, 2022 · 0 comments · Fixed by #2019

Comments

@jindraivanek
Copy link
Contributor

Issue created from fantomas-online

Code

#if false
#endif

Error

System.ArgumentException: The input list was empty. (Parameter 'list')
   at Microsoft.FSharp.Collections.ListModule.Tail[T](FSharpList`1 list) in D:\a\_work\1\s\src\fsharp\FSharp.Core\list.fs:line 126
   at Fantomas.TokenParser.getDefineExprs@402-1.Invoke(Tuple`2 tupledArg) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/TokenParser.fs:line 424
   at Microsoft.FSharp.Collections.ListModule.Fold[T,TState](FSharpFunc`2 folder, TState state, FSharpList`1 list) in D:\a\_work\1\s\src\fsharp\FSharp.Core\list.fs:line 221
   at Fantomas.TokenParser.getDefineExprs(FSharpList`1 hashTokens) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/TokenParser.fs:line 400
   at Fantomas.TokenParser.getOptimizedDefinesSets(FSharpList`1 hashTokens) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/TokenParser.fs:line 433
   at Fantomas.TokenParser.getDefines(String sourceCode) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/TokenParser.fs:line 449
   at Fantomas.CodeFormatterImpl.parse(FSharpChecker checker, FSharpParsingOptions parsingOptions, FormatContext _arg1)
   at Fantomas.CodeFormatterImpl.format@401.Invoke(Unit unitVar) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodeFormatterImpl.fs:line 401
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 446
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 105

Problem description

Same problem with #if true.

Not crash with more complex constant like #if (true||false) but output is not correct. This could be different issue.

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 4.6 branch at 1/1/1990

Default Fantomas configuration

jindraivanek added a commit to jindraivanek/fantomas that referenced this issue Jan 12, 2022
jindraivanek added a commit to jindraivanek/fantomas that referenced this issue Jan 12, 2022
nojaf pushed a commit that referenced this issue Jan 13, 2022
* Consider true, false as compiler define identifiers.

Fix #2013
jindraivanek added a commit to jindraivanek/fantomas that referenced this issue Mar 30, 2022
…ers. (fsprojects#2019)

* Consider true, false as compiler define identifiers.

Fix fsprojects#2013
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