Closed
Description
Currently on the latest Julia release: 1.10.0
I observed this difference with 1.9:
struct TupleHolder
tuple::Type{<:Tuple}
end
do_thing(t::DataType) = println("DataType")
do_thing(t::UnionAll) = println("UnionAll")
call_thing(t::TupleHolder) = do_thing(t.tuple)
call_thing(TupleHolder(Tuple{}))
Outputs "UnionAll"
, which is unexpected since Tuple{} isa DataType
. In 1.9, it outputs "DataType"
.
By changing call_thing
to call_thing(t::TupleHolder) = (println(@which do_thing(t.tuple)); do_thing(t.tuple))
we get:
do_thing(t::DataType) @ Main REPL[2]:1
UnionAll
Meaning that there is a discrepancy between @which
and the method Julia chooses to call.
Adding println(typeof(t))
to do_thing(t::UnionAll)
outputs DataType
, which makes me think this is definitly a bug.
Interestingly, removing the ::Type{<:Tuple}
from the TupleHolder
declaration fixes the issue.