Skip to content

Commit b0343d5

Browse files
committed
inference: make getfield_tfunc more robust for abstract PartialStruct
We're currently careful never to make these. But good to be careful? refs #34513
1 parent 92337b5 commit b0343d5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

base/compiler/tfuncs.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -826,17 +826,19 @@ function getfield_tfunc(@nospecialize(s00), @nospecialize(name))
826826
end
827827
end
828828
s = typeof(sv)
829-
elseif isa(s, PartialStruct)
829+
elseif isa(s00, PartialStruct)
830+
s01 = widenconst(s00)
831+
s = unwrap_unionall(s01)::DataType
830832
if isa(name, Const)
831833
nv = name.val
832834
if isa(nv, Symbol)
833-
nv = fieldindex(widenconst(s), nv, false)
835+
nv = fieldindex(s, nv, false)
834836
end
835837
if isa(nv, Int) && 1 <= nv <= length(s.fields)
836-
return unwrapva(s.fields[nv])
838+
return unwrapva(s00.fields[nv])
837839
end
838840
end
839-
s = widenconst(s)
841+
s00 = s01
840842
end
841843
if isType(s) || !isa(s, DataType) || isabstracttype(s)
842844
return Any

0 commit comments

Comments
 (0)