You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the macro is inside a module, the @type is referring to the container module instead of the type where the macro is expanded.
Running the docs tool with the following code exhibits the differences. But the issue affects also the generated code.
I was expecting to always be the type were the macro is executed (since the otherone can be explicitly mentioned)
moduleXXXmacrom# This will be XXX (not ideal) `{{@type}}`deffoo
{{@type}}
endendendmacrom# This will be Foo (ideal) `{{@type}}`defbar
{{@type}}
endendclassFooXXX.m
m
end
pp! Foo.new.foo # => XXX
pp! Foo.new.bar # => Foo
Right now self inside macros gives an error because it has no meaning. We could make self work for this purpose: it's the type where the macro is defined. On the other hand, @type is the type where the macro is expanded.
When the macro happens inside a method, like:
classFoodeffoo
{{@type}}
endend
then @type and self will be the same. In the examples provided by @bcardiff@type will work as he expects it, which I think is what's expected, and self will return XXX inside XXX.m but will give an error saying "there's no self" inside the top-level macro m... just like what happens with regular methods.
If the macro is inside a module, the
@type
is referring to the container module instead of the type where the macro is expanded.Running the docs tool with the following code exhibits the differences. But the issue affects also the generated code.
I was expecting to always be the type were the macro is executed (since the otherone can be explicitly mentioned)
Extracted from #8994
The text was updated successfully, but these errors were encountered: