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
Phoenix.Component overrides the def and defp macros to annotate function heads with some pattern matching.
I believe because defparams creates a new method by calling Module.eval_quoted/2 this is somehow evaluating the ast returned by Phoenix.Component's def macro prematurely(? - tbh, I don't grok this perfectly yet)
But the error can be seen with code like the following:
In my own experiments it seems to work fine, but I'm not sure if I'm missing something.
(Of course, I could just call the macro before I use Phoenix.Component, but perhaps there's a more comprehensive fix)
The text was updated successfully, but these errors were encountered:
mpinkston
changed the title
Compile error when using defparams macro in Phoenix.Component
Compile error when using defparams macro in module that uses Phoenix.Component
Dec 19, 2023
Phoenix.Component
overrides thedef
anddefp
macros to annotate function heads with some pattern matching.I believe because
defparams
creates a new method by callingModule.eval_quoted/2
this is somehow evaluating the ast returned by Phoenix.Component'sdef
macro prematurely(? - tbh, I don't grok this perfectly yet)But the error can be seen with code like the following:
Is there a reason I'm not understanding that the
defparams
macro is usingModule.eval_quoted/2
rather than just defining the method directly?In other words, can't
Just be written as
In my own experiments it seems to work fine, but I'm not sure if I'm missing something.
(Of course, I could just call the macro before I use Phoenix.Component, but perhaps there's a more comprehensive fix)
The text was updated successfully, but these errors were encountered: