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

apply spacing between operators and all SynExpr.Const #1980

Merged

Conversation

baronfel
Copy link
Contributor

@baronfel baronfel commented Nov 24, 2021

Closes #1979 by forcing the use of a space between all Prefix Applications (typically operators) and any SynExpr.Const arguments.

This is a bit broader of a change than strictly speaking would be required. The only required change to prevent soundness bugs would be to detect if the const was a negative number in some form and apply spacing then, because the core bug is that removing the spacing transforms the expression from + (-2) to +- 2 in meaning, so the operator being applied changes. I think it's reasonable to enforce a single-space everywhere, and if necessary we could encode this in the style guide.

@@ -1226,3 +1226,40 @@ module Foo =
| true -> id
| false -> id)
"""

let operator_application_literal_values =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took this list of literals from the F# docs page, but strictly speaking it's not necessary. If we wanted to vary the behavior of the spacing then we'd use this to validate that.

Copy link
Contributor

@nojaf nojaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks Chet!

@nojaf nojaf merged commit c6314fc into fsprojects:master Nov 24, 2021
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

Successfully merging this pull request may close these issues.

Operator application to some literals doesn't preserve spacing
2 participants