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

Macro dump breaks compilation #4257

Closed
bew opened this issue Apr 7, 2017 · 2 comments
Closed

Macro dump breaks compilation #4257

bew opened this issue Apr 7, 2017 · 2 comments

Comments

@bew
Copy link
Contributor

bew commented Apr 7, 2017

This fails to compile: https://carc.in/#/r/1tx8

macro dump
  anything
end

Gives:

# ... a lot of error trace ... 

in /usr/lib/crystal/char.cr:704: expanding macro

      raise InvalidByteSequenceError.new("Invalid char value #{dump}")
                                                               ^

in macro 'dump' eval:1, line 1:

>  1.   anything

undefined local variable or method 'anything'

The issue lies at src/char.cr L704 where it expects to call Char#dump but instead calls the top level macro dump defined above, because macro lookup appends before method lookup.

Even tough the dump macro name is not that good for a top level macro, it could be a common issue easily reproducible with minimal code:

macro call
  anything
end

class A
  def call
    puts "method call"
  end
  
  def initialize
    call
  end
end

A.new

https://carc.in/#/r/1u15 (same error)

I don't think this can be simply resolved...

Note: if someone can find a better name for this issue... Ty

@Sija
Copy link
Contributor

Sija commented Apr 8, 2017

See #236.

@bew
Copy link
Contributor Author

bew commented Apr 8, 2017

I see I'm not the first one with this issue ^^
Thanks I'll close this one

@bew bew closed this as completed Apr 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants