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: fails when %{...} strings are used inside macros #4249

Closed
bcardiff opened this issue Apr 6, 2017 · 1 comment
Closed

Formatter: fails when %{...} strings are used inside macros #4249

bcardiff opened this issue Apr 6, 2017 · 1 comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler
Milestone

Comments

@bcardiff
Copy link
Member

bcardiff commented Apr 6, 2017

File: foo.cr

macro oh(name)
  {% begin %}
    raise %{Oh {{name.id}} }
  {% end %}
end

oh no

The program builds and run as expected

$ crystal src/foo.cr 
Oh no  (Exception)
0x10e749892: *CallStack::unwind:Array(Pointer(Void)) at ??
0x10e749831: *CallStack#initialize:Array(Pointer(Void)) at ??
0x10e749808: *CallStack::new:CallStack at ??
0x10e743b01: *raise<Exception>:NoReturn at ??
0x10e743ae1: *raise<String>:NoReturn at ??
0x10e743638: __crystal_main at ??
0x10e748ac8: main at ??

But it fails to format

$ crystal tool format src/foo.cr
Error:, couldn't format 'src/foo.cr', please report a bug ...

$ crystal --version
Crystal 0.21.1 (2017-03-07) LLVM 3.9.1

@bcardiff bcardiff added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:tools:formatter labels Apr 6, 2017
@bcardiff bcardiff changed the title Formatter: fails when %{...} string are used inside macros. Formatter: fails when %{...} strings are used inside macros Apr 6, 2017
@asterite
Copy link
Member

asterite commented Apr 7, 2017

This actually fails to compile:

macro x
  %{}
end
Syntax error in foo.cr:1: unterminated macro

macro x
      ^

@asterite asterite added this to the Next milestone Apr 7, 2017
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:compiler
Projects
None yet
Development

No branches or pull requests

2 participants