Skip to content

Commit 439edf6

Browse files
yoffCopilot
andcommitted
Python: test captured jump reassignment trade-off
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 1a8e317 commit 439edf6

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • python/ql/test/library-tests/dataflow/typetracking

‎python/ql/test/library-tests/dataflow/typetracking/test.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,24 @@ def inner():
7878
print(also_x) # $ tracked
7979

8080

81+
# ------------------------------------------------------------------------------
82+
# Captured variable reassignment
83+
# ------------------------------------------------------------------------------
84+
85+
def captured_reassignment_tradeoff():
86+
value = tracked # $ tracked
87+
88+
def read_value():
89+
return value # $ tracked
90+
91+
before_reassignment = read_value() # $ tracked
92+
value = "safe"
93+
safe_sibling = read_value() # $ SPURIOUS: tracked
94+
95+
before_reassignment # $ tracked
96+
safe_sibling # $ SPURIOUS: tracked
97+
98+
8199
# ------------------------------------------------------------------------------
82100
# Function decorator
83101
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)