Skip to content

Conversation

HertzDevil
Copy link
Contributor

Errors for Def nodes are reported at their names:

macro f(x)
  {% x.foo %}
end

f(def foo; end)
#  5 | f(def foo; end)
#            ^--
# Error: undefined macro method 'Def#foo'

{% Array.methods[0].foo %}
#  145 | def initialize(size : Int, value : T)
#            ^---------
# Error: undefined macro method 'Def#foo'

Errors for both top-level and lib funs are not:

macro f(x)
  {% x.foo %}
end

f(fun foo; end)
#  5 | f(fun foo; end)
#        ^
# Error: undefined macro method 'FunDef#foo'

{% LibC.methods[0].foo %}
#  16 | fun dlclose(handle : Void*) : Int
#       ^------
# Error: undefined macro method 'External#foo'

This PR matches the latter's behavior with the former.

@HertzDevil HertzDevil added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:parser labels Jan 29, 2024
@straight-shoota straight-shoota added this to the 1.12.0 milestone Jan 29, 2024
@straight-shoota straight-shoota merged commit 8a2a1a8 into crystal-lang:master Jan 30, 2024
@HertzDevil HertzDevil deleted the bug/external-name-location branch January 30, 2024 20:28
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:parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants