Metaprogramming and variable scope (again)

You are running into a hygiene issue, and need to esc variables and expressions that you don’t want to be renamed for macro hygiene:

julia> macro foo(f) 
           quote
               $(esc(:x)) = 2
               $(esc(f))
           end
       end
2 Likes