mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
Python: Expand function reference in content test
This commit is contained in:
@@ -15,8 +15,9 @@ pointsTo_found_typeTracker_notFound
|
|||||||
| code/func_defined_outside_class.py:39:11:39:21 | ControlFlowNode for _gen() | B._gen |
|
| code/func_defined_outside_class.py:39:11:39:21 | ControlFlowNode for _gen() | B._gen |
|
||||||
| code/func_defined_outside_class.py:42:1:42:7 | ControlFlowNode for Attribute() | B._gen.func |
|
| code/func_defined_outside_class.py:42:1:42:7 | ControlFlowNode for Attribute() | B._gen.func |
|
||||||
| code/func_defined_outside_class.py:43:1:43:7 | ControlFlowNode for Attribute() | B._gen.func |
|
| code/func_defined_outside_class.py:43:1:43:7 | ControlFlowNode for Attribute() | B._gen.func |
|
||||||
|
| code/func_ref_in_content.py:17:1:17:4 | ControlFlowNode for f2() | func |
|
||||||
|
| code/func_ref_in_content.py:20:1:20:4 | ControlFlowNode for f3() | func |
|
||||||
| code/funky_regression.py:15:9:15:17 | ControlFlowNode for Attribute() | Wat.f2 |
|
| code/funky_regression.py:15:9:15:17 | ControlFlowNode for Attribute() | Wat.f2 |
|
||||||
| code/tuple_function_return.py:15:1:15:4 | ControlFlowNode for f2() | func |
|
|
||||||
| code/type_tracking_limitation.py:8:1:8:3 | ControlFlowNode for x() | my_func |
|
| code/type_tracking_limitation.py:8:1:8:3 | ControlFlowNode for x() | my_func |
|
||||||
typeTracker_found_pointsTo_notFound
|
typeTracker_found_pointsTo_notFound
|
||||||
| code/callable_as_argument.py:29:5:29:12 | ControlFlowNode for Attribute() | test_class.InsideTestFunc.sm |
|
| code/callable_as_argument.py:29:5:29:12 | ControlFlowNode for Attribute() | test_class.InsideTestFunc.sm |
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
def func():
|
||||||
|
print("func()")
|
||||||
|
|
||||||
|
def return_func():
|
||||||
|
return func
|
||||||
|
|
||||||
|
f1 = return_func() # $ pt,tt=return_func
|
||||||
|
f1() # $ pt,tt=func
|
||||||
|
|
||||||
|
|
||||||
|
def return_func_in_tuple():
|
||||||
|
return (func, 42)
|
||||||
|
|
||||||
|
tup = return_func_in_tuple() # $ pt,tt=return_func_in_tuple
|
||||||
|
|
||||||
|
f2, _ = tup
|
||||||
|
f2() # $ pt=func MISSING: tt
|
||||||
|
|
||||||
|
f3 = tup[0]
|
||||||
|
f3() # $ pt=func MISSING: tt
|
||||||
|
|
||||||
|
|
||||||
|
def return_func_in_dict():
|
||||||
|
return {'func': func, 'val': 42}
|
||||||
|
|
||||||
|
dct = return_func_in_dict() # $ pt,tt=return_func_in_dict
|
||||||
|
|
||||||
|
f4 = dct['func']
|
||||||
|
f4() # $ MISSING: tt=func
|
||||||
|
|
||||||
|
|
||||||
|
def return_func_in_dict_update():
|
||||||
|
d = {}
|
||||||
|
d["func"] = func
|
||||||
|
return d
|
||||||
|
|
||||||
|
dct2 = return_func_in_dict_update() # $ pt,tt=return_func_in_dict_update
|
||||||
|
|
||||||
|
f5 = dct2['func']
|
||||||
|
f5() # $ MISSING: tt=func
|
||||||
|
|
||||||
|
|
||||||
|
def return_func_in_list():
|
||||||
|
return [func, 42]
|
||||||
|
|
||||||
|
lst = return_func_in_list() # $ pt,tt=return_func_in_list
|
||||||
|
|
||||||
|
f6 = lst[0]
|
||||||
|
f6() # $ MISSING: pt,tt=func
|
||||||
|
|
||||||
|
if eval("False"): # don't run this, but fool analysis to still consider it (doesn't wok if you just to `if False:`)
|
||||||
|
f7 = lst[1]
|
||||||
|
f7()
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
def func():
|
|
||||||
print("func()")
|
|
||||||
|
|
||||||
def return_func():
|
|
||||||
return func
|
|
||||||
|
|
||||||
def return_func_in_tuple():
|
|
||||||
return (func, 42)
|
|
||||||
|
|
||||||
f1 = return_func() # $ pt,tt=return_func
|
|
||||||
f1() # $ pt,tt=func
|
|
||||||
|
|
||||||
|
|
||||||
f2, _ = return_func_in_tuple() # $ pt,tt=return_func_in_tuple
|
|
||||||
f2() # $ pt=func MISSING: tt
|
|
||||||
Reference in New Issue
Block a user