Closed
Description
This code used to work (I don't remember the version and I didn't managed to bisect that properly with versions before 0.21.0):
module ModuleName
macro method_added(meth)
{% puts "Method #{meth.name} added" %}
{{meth}}
end
# triggers the hook
def normal_method
end
end
It used to be called once, display the proper message, and defines the method.
(In fact this is a bad example, see #5066 (comment) for a better one!)
Now I get:
"Method normal_method added"
"Method normal_method added"
"Method normal_method added"
"Method normal_method added"
...
Followed by a stackoverflow error...
This is because the macro is expanded to:
def normal_method
end
and during the interpretation of the macro expansion, the macro method_added
is called (again) for the generated method.
I think that methods defined by a method_added
expansion should not trigger method_added
again, but methods defined in other places (normal code or other macros) should trigger it.
Metadata
Metadata
Assignees
Labels
No labels