Skip to content

Commit 3d2de03

Browse files
committed
Python: Add type-tracking test for attr set in function
1 parent dcd448b commit 3d2de03

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ def test_incompatible_types():
3030
x.field = str("Hello") # $str=field str SPURIOUS: int=field int
3131
expects_string(x) # $ str=field SPURIOUS: int=field
3232

33+
# set in different function
34+
def set_foo(some_class_instance): # $ tracked=foo
35+
some_class_instance.foo = tracked # $ tracked=foo tracked
36+
37+
def test_set_x():
38+
x = SomeClass()
39+
set_foo(x)
40+
print(x.foo) # MISSING: tracked
41+
3342
# ------------------------------------------------------------------------------
3443
# Attributes assigned statically to a class
3544
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)