-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
More robust trailing expressions newline implementation #15614
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
More robust trailing expressions newline implementation #15614
Conversation
Why tag this as |
My thinking was that stringification is related to macros so this Yea, if you have: macro finished
{% verbatim do %}
{%
to_process = [] of Nil
to_process.each do
b = 2
a = 1
end
raise "oh noes"
%}
{% end %}
end Without this PR: $ crystal run --error-trace test.cr
In test.cr:1:1
1 | macro finished
^
Error: expanding macro
...
> 1 |
> 2 | {%
> 3 | to_process = [] of Nil
> 4 |
> 5 | to_process.each do
> 6 | b = 2
> 7 | a = 1 end
> 8 |
> 9 | raise("oh noes")
> 10 | %}
> 11 |
Error: oh noes With this PR: $ ccrystal run --error-trace test.cr
Using compiled compiler at /home/george/dev/git/crystal/.build/crystal
In test.cr:1:1
1 | macro finished
^
Error: expanding macro
...
> 1 |
> 2 | {%
> 3 | to_process = [] of Nil
> 4 |
> 5 | to_process.each do
> 6 | b = 2
> 7 | a = 1
> 8 | end
> 9 |
> 10 | raise("oh noes")
> 11 | %}
> 12 |
Error: oh noes |
No, this is really just compiler behaviour. Not a language feature change. |
Follow up to #15305 to handle another edge case I noticed.
Before this PR if you had a macro expression whose body is an Expressions node, and the last node of those expressions was a Block or If statement, the
end
keyword would be on the wrong line. For examplewould be stringified as:
This PR resolves this and adds more test coverage on similar cases.
Supersedes #15613