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

F# Range Operator (..) with negative numbers produces invalid F# code and idempotent #3105

Closed
3 of 4 tasks
berkhoutalex opened this issue Aug 14, 2024 · 2 comments · Fixed by #3106
Closed
3 of 4 tasks

Comments

@berkhoutalex
Copy link

Issue created from fantomas-online

Code

[|-24.0 .. -1.0 .. -30.0|]

Result

[| -24.0 ..- 1.0 ..- 30.0 |]

Problem description

When making an F# range with a negative increment, the formatter produces invalid code after the first run. Then after running again, it produces different invalid 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 1/1/1990

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.

@berkhoutalex
Copy link
Author

As a workaround, you can rewrite it as
[|-24. .. -1. .. -30.|]
and it seems to work correctly

@nojaf
Copy link
Contributor

nojaf commented Aug 16, 2024

Hello,

Thank you for reporting this issue. I believe I have found a fix for this.

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