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

Handle imports with "as" and "if" clauses in either order. #1555

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

munificent
Copy link
Member

PR #1550 fixed the bug where if you had both clauses, it would output them in the wrong order. But it turns out that the parser today allows them in either order even though the language spec doesn't.

Since I've seen a handful of cases like this in the wild, instead of just failing to format, simply preserve the clause order that the user wrote.

PR #1550 fixed the bug where if you had both clauses, it would output
them in the *wrong* order. But it turns out that the parser today allows
them in *either* order even though the language spec doesn't.

Since I've seen a handful of cases like this in the wild, instead of
just failing to format, simply preserve the clause order that the user
wrote.
@natebosch
Copy link
Member

instead of just failing to format

Does it fail to format, or does it change the order to the correct one in the formatted code?

@munificent
Copy link
Member Author

Prior to this PR, it would change the order to the correct one in the formatter output. But that would then cause the formatter's own internal "I only make whitespace changes" sanity check to fail since it would see that as a non-whitespace change, which would then cause the formatter to abort writing that file.

With this PR, it just keeps the order that the user wrote, which also then means it is only making whitespace changes.

@natebosch
Copy link
Member

Oh I see from the other thread it trips the detection that something other than whitespace changed...

@munificent munificent merged commit d3b5aed into main Sep 4, 2024
7 checks passed
@munificent munificent deleted the import-clauses-out-of-order branch September 4, 2024 22:31
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.

2 participants