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
I was trying to use macro for annotation parameter which I thought would be okay since macros are applied during compile time. However, the compiler throws an error annotation argument needs to be a constant.
Here I defined a macro that returns without doing anything, so the Expr it's returning would be the same as it's given, which would be something of Literal(Constant(String)).
The @annot is just a plain annotation with one member String foo that I defined in Java
I found that the macro def is executed before the moment the arguments are checked whether constant. So, what I thought was: when the compiler is checking the arguments if they're constant, theidentity("bar") will have been converted to "bar" since the macro is already executed, which apparently is not what's happening.
Not sure if this is a bug, but I want to know if this is as intended by the design of the language.
The text was updated successfully, but these errors were encountered:
I was trying to use macro for annotation parameter which I thought would be okay since macros are applied during compile time. However, the compiler throws an error
annotation argument needs to be a constant.
Example:
Here I defined a macro that returns without doing anything, so the Expr it's returning would be the same as it's given, which would be something of
Literal(Constant(String))
.The
@annot
is just a plain annotation with one memberString foo
that I defined in JavaI found that the macro def is executed before the moment the arguments are checked whether constant. So, what I thought was: when the compiler is checking the arguments if they're constant, the
identity("bar")
will have been converted to"bar"
since the macro is already executed, which apparently is not what's happening.Not sure if this is a bug, but I want to know if this is as intended by the design of the language.
The text was updated successfully, but these errors were encountered: