-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requeststypes and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch
Description
I'd like this to work:
function f end
function g end
function (::Union{typeof(f),typeof(g)})()
7
end
using Test
@test f() === g()
However, it doesn't work:
julia> function f end
f (generic function with 0 methods)
julia> function g end
g (generic function with 0 methods)
julia> function (::Union{typeof(f),typeof(g)})()
7
end
ERROR: Method dispatch is unimplemented currently for this method signature
Stacktrace:
[1] top-level scope
@ REPL[3]:1
julia> versioninfo()
Julia Version 1.12.0-DEV.617
Commit 337b952625d (2024-05-29 13:31 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)
This would occasionally be nice for defining a single method for several functions, to prevent code duplication.
Metadata
Metadata
Assignees
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requeststypes and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch