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 formatting {% verbatim do %} ... {% end %} outside macro #6667

Conversation

makenowjust
Copy link
Contributor

This script crashes crystal tool format:

p!(
  {% verbatim do %}
    1
    {{2}}
    3
  {% end %}
)
$ crystal tool format foo.cr
Error: couldn't format 'foo.cr', please report a bug including the contents of it: https://github.com/crystal-lang/crystal/issues

expecting MACRO_CONTROL_START, not `{%, `, at :2:3 (Exception)
  from Crystal::Formatter#check<Symbol>:Nil
  from Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::Formatter>:(Bool | Nil)
  from Crystal::Formatter#format_args_simple<Array(Crystal::ASTNode+), Int32, Bool>:Tuple(Bool, Bool, Int32)
  from Crystal::Formatter#format_args<Array(Crystal::ASTNode+), Bool, (Array(Crystal::NamedArgument) | Nil), (Crystal::ASTNode+ | Nil), Int32, Bool>:Tuple(Bool | Nil, Bool, Int32)
  from Crystal::Formatter#visit<Crystal::Call>:Bool
  from Crystal::ASTNode+@Crystal::ASTNode#accept<Crystal::Formatter>:(Bool | Nil)
  from Crystal::format<String, String>:String
  from Crystal::Command#tool:(Bool | Nil)
  from Crystal::Command#run:(Bool | Crystal::Compiler::Result | Nil)
  from main

This PR fixes it.

@RX14 RX14 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler topic:tools:formatter topic:stdlib:macros labels Sep 6, 2018
Copy link
Member

@sdogruyol sdogruyol left a comment

Choose a reason for hiding this comment

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

Thank you @makenowjust 👍

@sdogruyol sdogruyol merged commit 14f411e into crystal-lang:master Sep 6, 2018
@sdogruyol sdogruyol added this to the 0.27.0 milestone Sep 6, 2018
@makenowjust makenowjust deleted the fix/crystal-format/verbatim-outside-macro branch September 6, 2018 16:33
ezrast pushed a commit to ezrast/crystal that referenced this pull request Oct 2, 2018
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.

4 participants