diff --git a/base/compiler/typelimits.jl b/base/compiler/typelimits.jl index 23045c65cc6bb..e3053add8f6ec 100644 --- a/base/compiler/typelimits.jl +++ b/base/compiler/typelimits.jl @@ -381,22 +381,21 @@ function tmerge(@nospecialize(typea), @nospecialize(typeb)) (isa(typeb, PartialStruct) || isa(typeb, Const)) && widenconst(typea) === widenconst(typeb) - typea_nfields = nfields_tfunc(typea) - typeb_nfields = nfields_tfunc(typeb) - if !isa(typea_nfields, Const) || !isa(typeb_nfields, Const) || typea_nfields.val !== typeb_nfields.val + typea_nfields = nfields_tfunc(typea) + typeb_nfields = nfields_tfunc(typeb) + if !isa(typea_nfields, Const) || !isa(typeb_nfields, Const) || typea_nfields.val !== typeb_nfields.val return widenconst(typea) - end + end - type_nfields = typea_nfields.val::Int - fields = Vector{Any}(undef, type_nfields) - anyconst = false - for i = 1:type_nfields + type_nfields = typea_nfields.val::Int + fields = Vector{Any}(undef, type_nfields) + anyconst = false + for i = 1:type_nfields fields[i] = tmerge(getfield_tfunc(typea, Const(i)), getfield_tfunc(typeb, Const(i))) anyconst |= has_nontrivial_const_info(fields[i]) - end - return anyconst ? PartialStruct(widenconst(typea), fields) : - widenconst(typea) + end + return anyconst ? PartialStruct(widenconst(typea), fields) : widenconst(typea) end if isa(typea, PartialOpaque) && isa(typeb, PartialOpaque) && widenconst(typea) == widenconst(typeb) if !(typea.source === typeb.source &&