Skip to content

Commit e8df15a

Browse files
committed
Fixed unparsing of function calls to subscripts like func<T>(args)
1 parent 24f6d1e commit e8df15a

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

transpyle/cpp/unparser.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def _Attribute(self, t):
511511

512512
def _Call(self, t):
513513
func_name = horast.unparse(t.func).strip()
514-
514+
515515
if func_name == 'np.zeros':
516516
self._includes['valarray'] = True
517517
self.write('std::valarray<')
@@ -527,10 +527,10 @@ def _Call(self, t):
527527
comma = True
528528
self.dispatch(arg)
529529
return
530-
530+
531531
if t.keywords:
532532
self._unsupported_syntax(t, 'with keyword arguments')
533-
533+
534534
if func_name == 'print':
535535
self._includes['iostream'] = True
536536
self.write('std::cout << ')
@@ -543,7 +543,17 @@ def _Call(self, t):
543543
self.dispatch(arg)
544544
return
545545

546-
super()._Call(t)
546+
self.dispatch_type(t.func)
547+
self.write('(')
548+
549+
comma = False
550+
for arg in t.args:
551+
if comma:
552+
self.write(", ")
553+
else:
554+
comma = True
555+
self.dispatch(arg)
556+
self.write(')')
547557

548558
# def _Subscript(self, t):
549559
# super()._Subscript(t)

0 commit comments

Comments
 (0)