Skip to content

Commit

Permalink
inference: make getfield_tfunc more robust for abstract PartialStruct
Browse files Browse the repository at this point in the history
We're currently careful never to make these. But good to be careful?

refs #34513
  • Loading branch information
vtjnash committed Aug 31, 2021
1 parent 92337b5 commit b0343d5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -826,17 +826,19 @@ function getfield_tfunc(@nospecialize(s00), @nospecialize(name))
end
end
s = typeof(sv)
elseif isa(s, PartialStruct)
elseif isa(s00, PartialStruct)
s01 = widenconst(s00)
s = unwrap_unionall(s01)::DataType
if isa(name, Const)
nv = name.val
if isa(nv, Symbol)
nv = fieldindex(widenconst(s), nv, false)
nv = fieldindex(s, nv, false)
end
if isa(nv, Int) && 1 <= nv <= length(s.fields)
return unwrapva(s.fields[nv])
return unwrapva(s00.fields[nv])
end
end
s = widenconst(s)
s00 = s01
end
if isType(s) || !isa(s, DataType) || isabstracttype(s)
return Any
Expand Down

0 comments on commit b0343d5

Please sign in to comment.