-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Description
🐛 Describe the bug
In a recent PR - #132912 - we came across a nasty silent incorrectness bug. This prompted me to think about a few invariants that we should maintain
- if
var.mutable_localisMutableSideEffects-var.sourcemust not be None - if
var.mutable_localisMutableLocal-var.sourcemust be None (this was in violation in the above issue, making side effects infra to do funky things) - if
var.mutable_localisNone- var must be aConstantVariable(this could be relaxed and needs more thought, TupleVariable with constants etc) - This will ensure that we track mutable_local correctly in all cases.
We should probably change the attr name mutable_local to something else. The local in the name suggest to me that the tracked object is created inside the frame (as opposed to existing). Some suggestions for rename are
var.mutable_local to var.mutation_type (Not fully convinced that this good name, suggestions welcome)
MutableLocal to MutableNew (even local is confusing - is it from f_locals? Or is it created inside the frame?)
MutableSideEffects to MutableExisting (opposite of MutableNew)
cc @ezyang @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @amjames @jansel if this makes sense.
Error logs
No response
Minified repro
No response
Versions
NA