Skip to content

Commit b6123de

Browse files
committed
Python: simplify assignments to captured variables
1 parent 2a5736e commit b6123de

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,11 @@ module LocalFlow {
299299
nodeTo.(CfgNode).getNode() = def.getDefiningNode()
300300
)
301301
or
302-
// General definition
303-
// TODO: remove other cases that are now redundant
302+
// Assignment to captured variables
303+
// These are not covered by the `AssignmentDefinition`s in the case above,
304+
// as they are not necessarily live.
304305
nodeFrom.(CfgNode).getNode() = nodeTo.(CfgNode).getNode().(DefinitionNode).getValue() and
305-
// remove jump steps (such as assignment of parameter default values)
306-
nodeFrom.getEnclosingCallable() = nodeTo.getEnclosingCallable()
306+
nodeTo.asExpr() = any(VariableCapture::CapturedVariable c).getAStore()
307307
or
308308
// With definition
309309
// `with f(42) as x:`

0 commit comments

Comments
 (0)