@deprecate of call overload

module MyModule
    struct AAA end
    Base.one(A::AAA) = 1
    @deprecate zero(A::AAA) one(A::AAA)
end
MyModule.zero(MyModule.AAA())
┌ Warning: `zero(A::AAA)` is deprecated, use `one(A::AAA)` instead.
│   caller = top-level scope at REPL[7]:1
└ @ Core REPL[7]:1
1
module MyModule
    struct AAA end
    Base.one(A::AAA) = 1
    @deprecate (A::AAA)() one(A::AAA)
end
ERROR: LoadError: invalid usage of @deprecate
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] @deprecate(::LineNumberNode, ::Module, ::Any, ::Any, ::Bool) at ./deprecated.jl:57
 [3] @deprecate(::LineNumberNode, ::Module, ::Any, ::Any) at ./deprecated.jl:34
in expression starting at REPL[4]:4

Is this a bug or there is a call like function to deprecate instead of (A::AAA)()?

I don’t know if the @deprecate macro works here, but you can always call Base.depwarn manually and achieve the same result:

julia> struct Foo
       end

julia> function (f::Foo)()
         Base.depwarn("(::Foo)() is deprecated", :foo_call_overload)
       end

julia> f = Foo()
Foo()

julia> f()
┌ Warning: (::Foo)() is deprecated
│   caller = ip:0x0
└ @ Core :-1
1 Like