Python: Add funky call-graph regression

I don't even know how to phrase this :D
This commit is contained in:
Rasmus Wriedt Larsen
2022-10-24 14:14:08 +02:00
parent 1e96ced3ab
commit 16483f7d40
2 changed files with 64 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ 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: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/funky_regression.py:15:9:15:17 | ControlFlowNode for Attribute() | Wat.f2 |
| code/type_tracking_limitation.py:8:1:8:3 | ControlFlowNode for x() | my_func |
typeTracker_found_pointsTo_notFound
| code/callable_as_argument.py:29:5:29:12 | ControlFlowNode for Attribute() | test_class.InsideTestFunc.sm |

View File

@@ -0,0 +1,63 @@
# When this regression was discovered, we did not resolve the `self.f2()` call after the
# try-except block, but ONLY when passing an attribute to a method, as indicated in the
# other tests below.
class Wat(object):
def f1(self, arg): pass
def f2(self): pass
def func(self, foo):
try:
self.f1(foo.bar) # $ pt,tt=Wat.f1
except Exception as e:
raise e
self.f2() # $ pt=Wat.f2 MISSING: tt=Wat.f2
# ==============================================================================
# variants that we are able to handle
# ==============================================================================
class Works(object):
"not using attribute"
def f1(self, arg): pass
def f2(self): pass
def func(self, foo):
try:
self.f1(foo) # $ pt,tt=Works.f1
except Exception as e:
raise e
self.f2() # $ pt,tt=Works.f2
class AlsoWorks(object):
"no exception"
def f1(self, arg): pass
def f2(self): pass
def func(self, foo):
self.f1(foo.bar) # $ pt,tt=AlsoWorks.f1
self.f2() # $ pt,tt=AlsoWorks.f2
def safe_func(arg):
pass
class Works3(object):
"call to non-self function"
def f1(self, arg): pass
def f2(self): pass
def func(self, foo):
try:
safe_func(foo.bar) # $ pt,tt=safe_func
except Exception as e:
raise e
self.f2() # $ pt,tt=Works3.f2