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

Indent right side expressions in assignments where the left side includes a type declaration #15429

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mverzilli
Copy link

Fixes #15421

With this change, the examples given by issue OP work as expected:

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

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

@Blacksmoke16 Blacksmoke16 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:tools:formatter labels Feb 7, 2025
@straight-shoota straight-shoota added this to the 1.16.0 milestone Feb 7, 2025
src/compiler/crystal/tools/formatter.cr Outdated Show resolved Hide resolved
@straight-shoota straight-shoota removed this from the 1.16.0 milestone Feb 8, 2025
@straight-shoota straight-shoota added this to the 1.16.0 milestone Feb 10, 2025
@straight-shoota
Copy link
Member

Need to apply the formatter.

@ysbaddaden
Copy link
Contributor

@mverzilli This is tricky: you fixed the formatter and this is affecting the crystal source code, so you must compile a local compiler then use it to format the source code. That will fix CI.

$ make crystal
$ bin/crystal tool format

Note: don't format the lib folder. It's vendored shard dependencies.

@straight-shoota
Copy link
Member

Shorter: make crystal format. Takes care of formatting the right directories.

@mverzilli
Copy link
Author

so you must compile a local compiler then use it to format the source code

🤦 that was a dumb omission. I'll try to squeeze that in tomorrow. Thanks for the patience!

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
Development

Successfully merging this pull request may close these issues.

Formatter does not indent case and if when the result is explicitly typed
4 participants