Skip to content

Wrong call of DataType method with UnionAll argument causes segfault #52644

Closed
@Keluaa

Description

@Keluaa

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.

Metadata

Metadata

Assignees

Labels

compiler:optimizerOptimization passes (mostly in base/compiler/ssair/)regression 1.10Regression in the 1.10 release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions