#[contractimpl]
also copies the procedural macros for the helper functions
#1426
Labels
bug
Something isn't working
What did you do?
Tried to annotate a smart contract function with a custom macro, and it failed miserably due to how
#[contractimpl]
macro expands.More background: we are writing a
pausable
extension for smart contracts, and we wanted to be able to annotate the functions with#[when_paused]
and#[when_not_paused]
instead of polluting the function body.Our macro requires the first parameter of the annotated function to be of type
&Env
orEnv
.And here is the relevant snippet of our code:
So far so good...
However, when this macro is put to action inside
#[contractimpl]
, the below errors occur.I was able to expand the
#[contractimpl]
macro and see the root of the error. Below are the relevant snippets that is generated by the#[contractimpl]
expansion (helper functions on related toemergency_reset
function):TL;DR
Problem
I think I know the problem already (I've dealt with procedural macros myself).
#[contractimpl]
macro copies the function name, and creates the necessary helper functions. However, during the process, it keeps the macro annotations for these copies as well. And I think, no macros should be preserved for these copies.Solution
#[contractimpl]
macro should not keep the macros that are annotating the function for the generated helper functions, it should only preserve the macro for the original function.The text was updated successfully, but these errors were encountered: