Skip to content

Functors are not valid targets for @patch #84

@omus

Description

@omus
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions