Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions pythran/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,19 @@ def visit_Compare(self, node):
return " and ".join(op(x, y) for x, op, y in all_cmps)

def visit_Call(self, node):
args = [self.visit(n) for n in node.args]
args = []
args_cast = []
for arg in node.args:
args.append(self.visit(arg))
if isinstance(arg, ast.Name):
args_cast.append("")
else:
arg_ty = self.types.get(arg, None)
if isinstance(arg_ty, self.types.builder.CombinedTypes):
args_cast.append("({})".format(arg_ty))
else:
args_cast.append("")

func = self.visit(node.func)
# special hook for getattr, as we cannot represent it in C++
if func == 'pythonic::builtins::functor::getattr{}':
Expand All @@ -925,7 +937,9 @@ def visit_Call(self, node):
+ node.args[1].value.upper(),
args[0]))
else:
return "{}({})".format(func, ", ".join(args))
return "{}({})".format(
func,
", ".join("{}{}".format(*z) for z in zip(args_cast, args)))

def visit_Constant(self, node):
if node.value is None:
Expand Down
10 changes: 10 additions & 0 deletions pythran/tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,3 +677,13 @@ def numpy_array_combiner5(n):
else:
return np.arange(n)[1:-1]'''
return self.run_test(code, 6, numpy_array_combiner5=[int])

def test_typing_rvalue0(self):
code = '''
def foo(x, n):
x.append(n)
return x
def typing_rvalue0(n):
return foo([], n)'''
return self.run_test(code, 6, typing_rvalue0=[int])