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 Jan 27, 2020
1 parent a5c422f commit 36ddc1a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -727,17 +727,21 @@ 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 s.fields[nv]
if isa(nv, Int)
if 1 <= nv <= length(s00.fields)
return s00.fields[nv]
end
end
end
s = widenconst(s)
s00 = s01
end
if isType(s) || !isa(s, DataType) || s.abstract
return Any
Expand Down

0 comments on commit 36ddc1a

Please sign in to comment.