Skip to content

Commit 457764f

Browse files
authored
inference: make getfield_tfunc more robust for abstract PartialStruct (#34541)
We're currently careful never to make these. But good to be careful? refs #34513
1 parent 613eea9 commit 457764f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

base/compiler/tfuncs.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -826,17 +826,18 @@ 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+
s = widenconst(s00)
831+
sty = unwrap_unionall(s)::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(sty, nv, false)
834836
end
835-
if isa(nv, Int) && 1 <= nv <= length(s.fields)
836-
return unwrapva(s.fields[nv])
837+
if isa(nv, Int) && 1 <= nv <= length(s00.fields)
838+
return unwrapva(s00.fields[nv])
837839
end
838840
end
839-
s = widenconst(s)
840841
end
841842
if isType(s) || !isa(s, DataType) || isabstracttype(s)
842843
return Any

0 commit comments

Comments
 (0)