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 Expr AppSingleParenArg Fantomas.Core.SyntaxOak+ExprAppSingleParenArgNode is uppercase or lowercase #3088

Closed
1 of 4 tasks
MangelMaxime opened this issue May 30, 2024 · 8 comments · Fixed by #3091
Labels
bug (soundness) good first issue Long hanging fruit: easy issue to get your feet wet!

Comments

@MangelMaxime
Copy link
Contributor

Note

I could not use Fantomas tool report this error because Github was complaining about the URL being too long but the code is already minimal (just a few characters)
I tried to manual respect the issue template

Related to #3086

Code and expected

let doc =
    x?a("")?b(t)

Result

Fantomas crash with

System.Exception: cannot determine if Expr AppSingleParenArg Fantomas.Core.SyntaxOak+ExprAppSingleParenArgNode is uppercase or lowercase
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1448.Invoke(String message)
   at Fantomas.Core.CodePrinter.sepSpaceBeforeParenInFuncInvocation(Expr functionExpr, Expr argExpr, Context ctx) in /_//src/Fantomas.Core/CodePrinter.fs:line 2522
   at Fantomas.Core.CodePrinter.genExpr@1028-197.Invoke(Context ctx)
   at Fantomas.Core.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /_//src/Fantomas.Core/Context.fs:line 430
   at Fantomas.Core.Context.shortExpressionWithFallback(FSharpFunc`2 shortExpression, FSharpFunc`2 fallbackExpression, Int32 maxWidth, FSharpOption`1 startColumn, Context ctx) in /_//src/Fantomas.Core/Context.fs:line 616
   at Fantomas.Core.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /_//src/Fantomas.Core/Context.fs:line 430
   at Fantomas.Core.Context.shortExpressionWithFallback(FSharpFunc`2 shortExpression, FSharpFunc`2 fallbackExpression, Int32 maxWidth, FSharpOption`1 startColumn, Context ctx) in /_//src/Fantomas.Core/Context.fs:line 616
   at Fantomas.Core.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /_//src/Fantomas.Core/Context.fs:line 430
   at Fantomas.Core.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /_//src/Fantomas.Core/Context.fs:line 430
   at Fantomas.Core.Context.col[T](FSharpFunc`2 f', IEnumerable`1 c, FSharpFunc`2 f, Context ctx) in /_//src/Fantomas.Core/Context.fs:line 463
   at Fantomas.Core.CodePrinter.genFile@4000-4.Invoke(Context ctx)
   at Fantomas.Core.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /_//src/Fantomas.Core/Context.fs:line 430
   at Fantomas.Core.Context.op_PlusGreater(FSharpFunc`2 ctx, FSharpFunc`2 f, Context x) in /_//src/Fantomas.Core/Context.fs:line 430
   at Fantomas.Core.CodeFormatterImpl.formatAST(ParsedInput ast, FSharpOption`1 sourceText, FormatConfig config, FSharpOption`1 cursor) in /_//src/Fantomas.Core/CodeFormatterImpl.fs:line 74
   at Fantomas.Core.CodeFormatterImpl.formatDocument@89-3.Invoke(Unit unitVar) in /_//src/Fantomas.Core/CodeFormatterImpl.fs:line 89
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 508
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112

Problem description

Fantomas is crashing

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.
  • I would like a release if this problem is solved.

Options

Fantomas v6.3.3+ccaee4a0756c8bc6f6717ae603915f6f5c52b09a

@MangelMaxime
Copy link
Contributor Author

A workaround this problem is to split the operation into several intermediate variables.

@nojaf nojaf added bug (soundness) good first issue Long hanging fruit: easy issue to get your feet wet! labels May 30, 2024
@nojaf
Copy link
Contributor

nojaf commented May 30, 2024

Would accept a PR for this.

@edgarfgp
Copy link
Contributor

I still seem to get this error System.Exception cannot determine if Expr Constant (FromText Fantomas.Core.SyntaxOak+SingleTextNode) is uppercase or lowercase at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1448.Invoke(String message) in version 7.0.1

@nojaf
Copy link
Contributor

nojaf commented Mar 18, 2025

Can you reproduce via online tool?

@edgarfgp
Copy link
Contributor

Can you reproduce via online tool?

Strange. I can't reproduce it with online tool. But when using 7.0.1 in Fabulous.AST with the following test:

    [<Fact>]
    let ``AppSingleParenArg expression``() =
        Oak() {
            AnonymousModule() {
                AppSingleParenArgExpr(
                    DynamicExpr(
                        AppSingleParenArgExpr(
                            DynamicExpr(AppSingleParenArgExpr(DynamicExpr("x", "a"), ParenExpr("")), "b"),
                            ParenExpr("t")
                        ),
                        "b"
                    ),
                    ParenExpr("t")
                )
            }
        }
        |> produces
            """
x?a("")?b(t)?b(t)
"""

@nojaf
Copy link
Contributor

nojaf commented Mar 20, 2025

The online tool doesn't produce x?a("")?b(t)?b(t) but adds some spaces in there.
Is that to be expected?

@MangelMaxime
Copy link
Contributor Author

Adding spacing on this line change the meaning of the code.

Instead of being a chain of property/method chain, it becomes calls to method.

For example, here is the result of Fable compilation even if this apply to normal F# code too I believe.

let test : obj = x?a("")?b(t)?b(t)

let test2 : obj = x?a ("")?b (t)?b (t)
export const test = ((x().a("")).b(t)).b(t);

export const test2 = x().a("".b, t.b, t);

@nojaf
Copy link
Contributor

nojaf commented Mar 20, 2025

Feel free to open an issue for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (soundness) good first issue Long hanging fruit: easy issue to get your feet wet!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants