Skip to content

Commit 4f7c877

Browse files
committed
Refine Slot on setfield!
1 parent 4bc3206 commit 4f7c877

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Compiler/src/abstractinterpretation.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,12 +2665,20 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
26652665
end
26662666
pushfirst!(argtypes, ft)
26672667
refinements = nothing
2668-
if sv isa InferenceState && f === typeassert
2669-
# perform very limited back-propagation of invariants after this type assertion
2670-
if rt !== Bottom && isa(fargs, Vector{Any})
2668+
if sv isa InferenceState
2669+
if f === typeassert
2670+
# perform very limited back-propagation of invariants after this type assertion
2671+
if rt !== Bottom && isa(fargs, Vector{Any})
2672+
farg2 = ssa_def_slot(fargs[2], sv)
2673+
if farg2 isa SlotNumber
2674+
refinements = SlotRefinement(farg2, rt)
2675+
end
2676+
end
2677+
elseif f === setfield! && length(argtypes) == 4 && isa(argtypes[3], Const)
26712678
farg2 = ssa_def_slot(fargs[2], sv)
26722679
if farg2 isa SlotNumber
2673-
refinements = SlotRefinement(farg2, rt)
2680+
refined = form_partially_defined_struct(argtypes[2], argtypes[3])
2681+
refinements = SlotRefinement(farg2, refined)
26742682
end
26752683
end
26762684
end

0 commit comments

Comments
 (0)