Skip to content

Commit f8c85e7

Browse files
Fix global effects behavior upon unknown alias
1 parent 9df09d2 commit f8c85e7

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

pythran/analyses/global_effects.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,15 @@ def visit_Call(self, node):
9999
func_aliases,
100100
list())
101101
for func_alias in func_aliases:
102-
# special hook for boundd functions
102+
# special hook for bound functions
103103
if isinstance(func_alias, ast.Call):
104104
bound_name = func_alias.args[0].id
105105
func_alias = self.global_declarations[bound_name]
106+
107+
# conservative choice
108+
if func_alias not in self.node_to_functioneffect:
109+
func_alias = intrinsic.UnboundValue
110+
106111
func_alias = self.node_to_functioneffect[func_alias]
107112
self.result.add_edge(self.current_function, func_alias)
108113
self.generic_visit(node)

pythran/tests/test_optimizations.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,3 +451,20 @@ def test_importedids(self):
451451

452452
def test_falsepoly(self):
453453
self.run_test("def falsepoly():\n i = 2\n if i:\n i='ok'\n else:\n i='lolo'\n return i", falsepoly=[])
454+
455+
def test_global_effects_unknown(self):
456+
code = '''
457+
def bb(x):
458+
return x[0]()
459+
460+
461+
def ooo(a):
462+
def aa():
463+
return a
464+
return aa,
465+
466+
def global_effects_unknown(a):
467+
return bb(ooo(a))'''
468+
self.run_test(code,
469+
1,
470+
global_effects_unknown=[int])

0 commit comments

Comments
 (0)