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 3a68be7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -826,17 +826,18 @@ function getfield_tfunc(@nospecialize(s00), @nospecialize(name))
end
end
s = typeof(sv)
elseif isa(s, PartialStruct)
elseif isa(s00, PartialStruct)
s = widenconst(s00)
sty = unwrap_unionall(s)::DataType
if isa(name, Const)
nv = name.val
if isa(nv, Symbol)
nv = fieldindex(widenconst(s), nv, false)
nv = fieldindex(sty, nv, false)
end
if isa(nv, Int) && 1 <= nv <= length(s.fields)
return unwrapva(s.fields[nv])
if isa(nv, Int) && 1 <= nv <= length(s00.fields)
return unwrapva(s00.fields[nv])
end
end
s = widenconst(s)
end
if isType(s) || !isa(s, DataType) || isabstracttype(s)
return Any
Expand Down

0 comments on commit 3a68be7

Please sign in to comment.