-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
Incorrect formatting in case
expression arm
#3136
Comments
Thanks |
It looks like this was an intentional choice https://github.com/gleam-lang/gleam/blob/main/compiler-core/src/format.rs#L1762-L1775 with the justification being in #2239 |
The above formatting doesn't seem to align with what is shown in the linked issue. Note how in my example there is no indentation of the arm, which definitely seems wrong. |
Ahhh my bad, i over focused in the arrow location. I'll try to take a look at this tomorrow night |
Bad news! The fix actually introduced another bug that resulted in a more common case being formatted badly. So we should reopen this and try and find a different way to format this code examples: the thing that I can't figure out is how to keep the arrow on the same line as the last clause. Here's some test cases we should keep in mind: fn test_1() {
case a, b, c {
_ignored, _ignored, _ignored
| _ignored, _ignored, _ignored
| _ignored, _ignored, _ignored
-> True
}
}
fn test_2() {
case a, b, c {
_, _, _
| _, _, _
| this_is_long_and_is_going_to_split_on_multiple,
lines,
and_force_the_arrow_to_break
-> True
}
}
fn test_3() {
case a, b, c {
_, _, _
| this_is_long_and_is_going_to_split_on_multiple,
lines,
and_force_the_alternative_to_break
| _, _, _
-> True
}
} For the time being I'll revert this fix so that RC-1.2 doesn't have the bug introduced by this fix |
While working on massivefermion/birl#24 I noticed some weird formatting applied by
gleam format
in Gleam v1.1.I pointed it out to @giacomocavalieri and he asked me to open an issue here.
Here is a slightly more minimized reproduction (repo):
I would expect something more like this:
Version Info
Gleam Logs
The text was updated successfully, but these errors were encountered: