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

"cannot determine if synExpr Paren" when Lambda after If expression #2015

Closed
1 of 3 tasks
jindraivanek opened this issue Jan 9, 2022 · 2 comments · Fixed by #2036
Closed
1 of 3 tasks

"cannot determine if synExpr Paren" when Lambda after If expression #2015

jindraivanek opened this issue Jan 9, 2022 · 2 comments · Fixed by #2036

Comments

@jindraivanek
Copy link
Contributor

Issue created from fantomas-online

Code

(if true then foo else goo) (fun _ -> 42)

Error

System.Exception: cannot determine if synExpr Paren
  (IfThenElse
     (tmp.fsx (1,1--1,3), false, Const (Bool true, tmp.fsx (1,4--1,8)),
      tmp.fsx (1,9--1,13), Ident foo, Some tmp.fsx (1,18--1,22),
      Some (Ident goo), Yes tmp.fsx (1,1--1,13), false, tmp.fsx (1,1--1,13),
      tmp.fsx (1,1--1,26)), tmp.fsx (1,0--1,1), Some tmp.fsx (1,26--1,27),
   tmp.fsx (1,0--1,27)) is uppercase or lowercase
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1439.Invoke(String message) in D:\a\_work\1\s\src\fsharp\FSharp.Core\printf.fs:line 1439
   at Fantomas.CodePrinter.sepSpaceAfterFunctionName@2074.Invoke(Context ctx) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodePrinter.fs:line 2074
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 502
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 502
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 502
   at Fantomas.Context.shortExpressionWithFallback(FSharpFunc`2 shortExpression, FSharpFunc`2 fallbackExpression, Int32 maxWidth, FSharpOption`1 startColumn, Context ctx) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 879
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 502
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 502
   at Fantomas.Context.col[T](FSharpFunc`2 f', IEnumerable`1 c, FSharpFunc`2 f, Context ctx) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 607
   at Fantomas.CodePrinter.genImpFile@96-6.Invoke(Context ctx) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodePrinter.fs:line 96
   at Fantomas.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/Context.fs:line 502
   at Fantomas.CodeFormatterImpl.formatWith(ParsedInput ast, FSharpList`1 defines, FSharpList`1 hashTokens, FormatContext formatContext, FormatConfig config) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodeFormatterImpl.fs:line 388
   at Fantomas.CodeFormatterImpl.mapping@408-1.Invoke(Unit unitVar) in /home/runner/work/fantomas-tools/fantomas-tools/.deps/fantomas/src/Fantomas/CodeFormatterImpl.fs:line 408
   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

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

@nojaf
Copy link
Contributor

nojaf commented Jan 10, 2022

This happens as well with (foo) (fun _ -> 42), I believe the Paren(Lambda _) might be relevant here.

@nojaf
Copy link
Contributor

nojaf commented Jan 10, 2022

As (if true then foo else goo) (42) does seem to work.

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