Skip to content

Commit 5736305

Browse files
committed
make datatype_min_ninitialized robust against non DataType input
By unwrapping the input type in `datatype_min_ninitialized`, and guard against non `DataType` input by returning the most conservative value `0` in such cases. - fixes #56997
1 parent 3b629f1 commit 5736305

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Compiler/src/typeutils.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ end
6464

6565
# Compute the minimum number of initialized fields for a particular datatype
6666
# (therefore also a lower bound on the number of fields)
67-
function datatype_min_ninitialized(t::DataType)
67+
function datatype_min_ninitialized(@nospecialize t0)
68+
t = unwrap_unionall(t0)
69+
t isa DataType || return 0
6870
isabstracttype(t) && return 0
6971
if t.name === _NAMEDTUPLE_NAME
7072
names, types = t.parameters[1], t.parameters[2]

0 commit comments

Comments
 (0)