Skip to content

Commit ebd97f4

Browse files
committed
Python: Add type-tracking regession example
1 parent 6674e07 commit ebd97f4

File tree

1 file changed

+24
-0
lines changed
  • python/ql/test/experimental/dataflow/typetracking

1 file changed

+24
-0
lines changed

python/ql/test/experimental/dataflow/typetracking/test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,27 @@ def test_long_import_chain_full_path():
158158
from foo.bar import baz # $ tracked_foo_bar_baz
159159
x = baz # $ tracked_foo_bar_baz
160160
do_stuff(x) # $ tracked_foo_bar_baz
161+
162+
# ------------------------------------------------------------------------------
163+
# Global variable to method body flow
164+
# ------------------------------------------------------------------------------
165+
166+
some_value = get_tracked() # $ tracked
167+
other_value = get_tracked() # $ tracked
168+
print(some_value) # $ tracked
169+
print(other_value) # $ tracked
170+
171+
class MyClass(object):
172+
# Since we define some_value method on the class, flow for some_value gets blocked
173+
# into the methods
174+
def some_value(self):
175+
print(some_value) # $ MISSING: tracked
176+
print(other_value) # $ tracked
177+
178+
def other_name(self):
179+
print(some_value) # $ MISSING: tracked
180+
print(other_value) # $ tracked
181+
182+
def with_global_modifier(self):
183+
global some_value
184+
print(some_value) # $ tracked

0 commit comments

Comments
 (0)