exaloop / exaloop/codon

Unable to pass a function as an argument

Open
#261 2 comments 1 reaction 1 assignee Claimed by @inumanag View on GitHub
Dominant language
Python
Stars
16.8k
Forks
603
Avg merge
4d 23h
Merged PRs (30d)
6

Description

**Description**

I am not able to pass a function as an argument, to python functions.
I found the issue by calling [`matplotlib.animation.FuncAnimation`](https://matplotlib.org/stable/api/_as_gen/matplotlib.animation.FuncAnimation.html).
However, the full code was too long, so I made a minimum example to reproduce.

**How to reproduce**
In codon v0.15.5:
```py
def add(a,b):
return a+b

@python
def debug(f):
print(f, type(f))

@python
def debug_call(f, args):
f(*args)

debug(add)
debug_call(add, (1, 3))
```

Result:
```
((), ())
PyError: 'tuple' object is not callable

Raised from: pyobj.exc_check:0
/home/minsoo/hobby/codon-deploy/lib/codon/stdlib/internal/python.codon:623:13

Backtrace:
[0x7f6a618a6c94] GCC_except_table193 at /home/minsoo/hobby/codon-deploy/lib/codon/stdlib/internal/python.codon:623:13
[0x7f6a618a6cc0] GCC_except_table193 at /home/minsoo/hobby/codon-deploy/lib/codon/stdlib/internal/python.codon:626:9
[0x7f6a618a7cba] GCC_except_table193 at /home/minsoo/hobby/codon-deploy/lib/codon/stdlib/internal/python.codon:650:68
[0x7f6a618a7d44] GCC_except_table193 at /home/minsoo/hobby/codon-playground/high_order.py:9:1
[0x7f6a618ae1c2] GCC_except_table193 at /home/minsoo/hobby/codon-playground/high_order.py:13:21
[1] 1244 abort ../codon-deploy/bin/codon run high_order.py
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.