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

Fantomas reports an error when formatting interpolated string with tripple quotes #3049

Closed
4 tasks
object opened this issue Feb 22, 2024 · 7 comments
Closed
4 tasks

Comments

@object
Copy link

object commented Feb 22, 2024

Issue created from fantomas-online

Code

let user = "abc"

let json = $$"""
{
  "id": "ABC",
  "name": "{{user}}",
};
"""

Result

let user = "abc"

let json =
    $$"""
{
  "id": "ABC",
  "name": "{{user}",
};
"""

Problem description

We configured out build to fail on fantomas errors. And if fails on this code. Here's the output from Fantomas:

Formatted │ 0 │ Ignored │ 60 │ Unchanged │ 252 │ Errored │ 1

Failed to format file: ./src/Bootstrapper/PhobosBootstrapper.fs : Formatting ./src/Bootstrapper/PhobosBootstrapper.fs leads to invalid F# code

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 main branch at 2024-02-15T12:00:55Z - 0700fd6

Default Fantomas configuration

Did you know that you can ignore files when formatting by using a .fantomasignore file?
PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

@dawedawe
Copy link
Member

dawedawe commented Feb 22, 2024

Thanks for reporting.
But I'll close this as a duplicate of #3012
It's a bug in the lexer of the compiler...

@nojaf
Copy link
Contributor

nojaf commented Feb 22, 2024

Hi Vagif! Thanks for the report, at some point I took a look at the lexer but didn't immediately find anything. This is a more challenging problem for sure.

@object
Copy link
Author

object commented Feb 22, 2024

@nojaf yes, apparently it is. I checked lexer issue, and looks like it was inspected by people much more knowledgeable than me in this area.

@nojaf
Copy link
Contributor

nojaf commented Mar 1, 2024

Hi @object, there should be a fix for this available in https://www.nuget.org/packages/fantomas/6.3.0-alpha-008

@object
Copy link
Author

object commented Mar 4, 2024

Cool, thanks a lot!

@object
Copy link
Author

object commented Mar 4, 2024

@nojaf Out of curiosity, what has been changed in the fix? I checked the commit files, and they only refer to package changes

https://github.com/fsprojects/fantomas/pull/3052/files

@nojaf
Copy link
Contributor

nojaf commented Mar 4, 2024

The problem was fixed over the compiler side in (dotnet/fsharp#16774, dotnet/fsharp#16785 and dotnet/fsharp#16796).

#3052 mostly updated our source dependency to include these fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants