Skip to content

Commit

Permalink
Refine Slot on setfield!
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Belmant committed Jan 31, 2025
1 parent dbe19e4 commit 0cca8e9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Compiler/src/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2660,12 +2660,20 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
end
pushfirst!(argtypes, ft)
refinements = nothing
if sv isa InferenceState && f === typeassert
# perform very limited back-propagation of invariants after this type assertion
if rt !== Bottom && isa(fargs, Vector{Any})
if sv isa InferenceState
if f === typeassert
# perform very limited back-propagation of invariants after this type assertion
if rt !== Bottom && isa(fargs, Vector{Any})
farg2 = ssa_def_slot(fargs[2], sv)
if farg2 isa SlotNumber
refinements = SlotRefinement(farg2, rt)
end
end
elseif f === setfield! && length(argtypes) == 4 && isa(argtypes[3], Const)
farg2 = ssa_def_slot(fargs[2], sv)
if farg2 isa SlotNumber
refinements = SlotRefinement(farg2, rt)
refined = form_partially_defined_struct(argtypes[2], argtypes[3])
refinements = SlotRefinement(farg2, refined)
end
end
end
Expand Down

0 comments on commit 0cca8e9

Please sign in to comment.