From b0343d5da61f90e7f3e498a1d4802cd9b1cf4b84 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 27 Jan 2020 16:22:27 -0500 Subject: [PATCH] inference: make getfield_tfunc more robust for abstract PartialStruct We're currently careful never to make these. But good to be careful? refs #34513 --- base/compiler/tfuncs.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/base/compiler/tfuncs.jl b/base/compiler/tfuncs.jl index a43c9dd9afff10..ce5d7069bd2087 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -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