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

Formatter does not indent case and if when the result is explicitly typed #15421

Open
BigBoyBarney opened this issue Feb 6, 2025 · 0 comments · May be fixed by #15429
Open

Formatter does not indent case and if when the result is explicitly typed #15421

BigBoyBarney opened this issue Feb 6, 2025 · 0 comments · May be fixed by #15429
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:tools:formatter

Comments

@BigBoyBarney
Copy link
Contributor

Hi!

I saw in #13002 that some people advocate for the removal of alignment in the formatter, which I personally think would be horrible, as I really like alignment, but that's besides the point.

The following cases work as expected, with nicely aligned if-else and case-when blocks.

x = if rand(2) == 1
      "One"
    else
      "Zero"
    end

x = case rand(2)
    when 0
      "Zero"
    when 1
      "One"
    end

If, however, the result, in this case x is explicitly typed, the formatter forces a 0 indent

x : String = if rand(2) == 1
  "One"
else
  "Zero"
end

x : String = case rand(2)
when 0
  "Zero"
when 1
  "One"
end
@BigBoyBarney BigBoyBarney added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:tools:formatter
Projects
None yet
2 participants