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

Fix formatter lib-fun declaration with newlines #12071

Merged

Conversation

ftarulla
Copy link
Collaborator

Fixes #12070

The formatter tool was crashing when trying to indent lib fun declarations with newlines.
For example:

lib Foo
  fun foo =
    bar : Void
end 

After this PR the formatter can handle such cases. Other example:

input:

lib Foo
  fun foo =


    bar : Void
end

output:

lib Foo
  fun foo =
    bar : Void
end

@Blacksmoke16 Blacksmoke16 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:tools:formatter labels May 26, 2022
@straight-shoota
Copy link
Member

straight-shoota commented May 27, 2022

This should also apply to cases where the function name is a string literal (which is handled in the first branch).

lib Foo
  fun foo =
    "bar"(Int32) : Int32
end

This example continues to raise a compiler error.

@ftarulla
Copy link
Collaborator Author

This should also apply to cases where the function name is a string literal (which is handled in the first branch).

lib Foo
  fun foo =
    "bar"(Int32) : Int32
end

This example continues to raise a compiler error.

Good catch! Thx @straight-shoota! I'll check it asap 🤓 👍

Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

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

🚀

@beta-ziliani beta-ziliani added this to the 1.5.0 milestone May 31, 2022
@straight-shoota straight-shoota merged commit 78d9782 into crystal-lang:master Jun 3, 2022
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.

Tool format crashes on line-broken library function declaration
4 participants