Open nsajko opened 5 months ago
NB: the same thing, method for a Union
, works fine as long as none of the types in the Union
were defined with function
. Example:
julia> struct T <: Function end
julia> struct S <: Function end
julia> (::Union{S,T})() = 7
julia> S()()
7
julia> @which S()()
(::Union{S, T})()
@ Main REPL[3]:1
julia> versioninfo()
Julia Version 1.12.0-DEV.766
Commit 9d8ecaa899d (2024-06-21 17:00 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
WORD_SIZE: 64
LLVM: libLLVM-17.0.6 (ORCJIT, znver2)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
I'd like this to work:
However, it doesn't work:
This would occasionally be nice for defining a single method for several functions, to prevent code duplication.