-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Synonymous macro and method lookup broken when called with different/implicit scope #4722
Comments
I think that you're mixing compile-time printing and runtime printing, the macro Using the following snippet, I get what I expect: module DSL
macro foo
"macro"
end
def foo
"method"
end
end
class Base
include DSL
def call_foo
foo
end
def call_foo_from_block
true.try do
foo
end
end
def call_self_foo
self.foo
end
end
b = Base.new
pp b.foo # => "method"
pp Base.new.foo # => "method"
pp Base.new.call_foo # => "macro"
pp Base.new.call_self_foo # => "method"
pp Base.new.call_foo_from_block # => "macro" |
Dough, your're right. Because of compile and runtime output the order is changed. Sorry that I missed that. But the modified code from your snippet does not behave as expected: the calls to |
@straight-shoota In #236, what I understand about the direction taken is that it first lookup a macro then a method, then go up one parent level, and try again to find a macro, then a method, etc... |
Seems like I get to find all the bugs related to macro lookup these days...
This might be related to #4639 but it is a bit different and already present in versions prior to
0.23.0
.Given the following types:
This works as expected: https://carc.in/#/r/2dqy
But suddenly
Base.new.foo
refers to the macro: https://carc.in/#/r/2dr0https://carc.in/#/r/2dqx
And it keeps going...
https://carc.in/#/r/2dr1
https://carc.in/#/r/2dqw
None of these calls should invoke the macro, all should point to the instance method in the implicit scope.
If the calls inside
call_foo
andcall_foo_with_block
are explicitly scoped, they are correctly mapped to the instance method.The text was updated successfully, but these errors were encountered: