@@ -633,6 +633,7 @@ function lines_required!(isrequired::AbstractVector{Bool}, objs, src::CodeInfo,
633
633
634
634
# So far, everything is generic graph traversal. Now we add some domain-specific information
635
635
changed |= add_typedefs! (isrequired, src, edges, typedefs, norequire)
636
+ changed |= add_inplace! (isrequired, src, edges, norequire)
636
637
637
638
iter += 1 # just for diagnostics
638
639
end
@@ -873,6 +874,30 @@ function add_typedefs!(isrequired, src::CodeInfo, edges::CodeEdges, (typedef_blo
873
874
return changed
874
875
end
875
876
877
+ # For arrays, add any `push!`, `pop!`, `empty!` or `setindex!` statements
878
+ # This is needed for the "Modify @enum" test in Revise
879
+ function add_inplace! (isrequired, src, edges, norequire)
880
+ changed = false
881
+ for (i, isreq) in pairs (isrequired)
882
+ isreq || continue
883
+ for j in edges. succs[i]
884
+ j ∈ norequire && continue
885
+ stmt = src. code[j]
886
+ if isexpr (stmt, :call ) && length (stmt. args) >= 2
887
+ arg = stmt. args[2 ]
888
+ if @isssa (arg) && arg. id == i
889
+ fname = stmt. args[1 ]
890
+ if is_quotenode_egal (fname, Base. push!) || is_quotenode_egal (fname, Base. pop!) || is_quotenode_egal (fname, Base. empty!) || is_quotenode_egal (fname, Base. setindex!)
891
+ changed |= ! isrequired[j]
892
+ isrequired[j] = true
893
+ end
894
+ end
895
+ end
896
+ end
897
+ end
898
+ return changed
899
+ end
900
+
876
901
"""
877
902
selective_eval!([recurse], frame::Frame, isrequired::AbstractVector{Bool}, istoplevel=false)
878
903
0 commit comments