Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,12 @@ module TypeTrackingInput implements Shared::TypeTrackingInput<Location> {
// nodeFrom is `expr`
// nodeTo is entry node for `f`
exists(
SsaImpl::ScopeEntryDefinition e, SsaImpl::SsaSourceVariable var, Cfg::DefinitionNode def
SsaImpl::ScopeEntryDefinition e, SsaImpl::SsaSourceVariable var,
SsaImpl::EssaNodeDefinition write, Cfg::DefinitionNode def
|
e.getSourceVariable() = var and
def.getNode() = var.getVariable().getAStore()
write.getSourceVariable() = var and
write.getDefiningNode() = def
|
nodeTo.(DataFlowPublic::ScopeEntryDefinitionNode).getDefinition() = e and
nodeFrom.asCfgNode() = def and
Expand Down
18 changes: 18 additions & 0 deletions python/ql/test/library-tests/dataflow/typetracking/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ def inner():
print(also_x) # $ tracked


# ------------------------------------------------------------------------------
# Captured variable reassignment
# ------------------------------------------------------------------------------

def captured_reassignment_tradeoff():
value = tracked # $ tracked

def read_value():
return value # $ MISSING: tracked

before_reassignment = read_value() # $ MISSING: tracked
value = "safe"
safe_sibling = read_value()

before_reassignment # $ MISSING: tracked
safe_sibling


# ------------------------------------------------------------------------------
# Function decorator
# ------------------------------------------------------------------------------
Expand Down