Mocking.jl icon indicating copy to clipboard operation
Mocking.jl copied to clipboard

Functors are not valid targets for `@patch`

Open omus opened this issue 4 years ago • 0 comments

julia> using Mocking

julia> struct A
           a
       end

julia> @patch function (a::A)(b) 1 end
ERROR: UndefVarError: a not defined
Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

Note that ExprTools.jl does handle functors properly:

julia> using ExprTools

julia> splitdef(:(function (a::A)(b) 1 end))
Dict{Symbol, Any} with 4 entries:
  :args => Any[:b]
  :body => quote…
  :name => :(a::A)
  :head => :function

omus avatar Mar 29 '21 20:03 omus