numba
numba copied to clipboard
TypyingError when combining variadic and optional arguments
import numba
@numba.njit
def foo(x, y, z=1):
return x + y + z
assert foo(1, 1) == 3
@numba.njit
def bar(*xy, z=1):
x, y = xy
return x + y + z
assert bar(1, 1) == 3 # Raises TypingError: failed to unpack int64
At some point in the inference it iterates over the xy tuple, thinking it is iterating over (xy, z) function arguments
I can confirm:
esc@artemis [numba_3.13] (git)-[main] ~/git/numba-issues python numba/10258/10258.py
Traceback (most recent call last):
File "/Users/esc/git/numba-issues/numba/10258/10258.py", line 14, in <module>
assert bar(1, 1) == 3 # Raises TypingError: failed to unpack int64
~~~^^^^^^
File "/Users/esc/git/numba/numba/core/dispatcher.py", line 424, in _compile_for_args
error_rewrite(e, 'typing')
~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/Users/esc/git/numba/numba/core/dispatcher.py", line 365, in error_rewrite
raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
failed to unpack int64
File "numba/10258/10258.py", line 11:
def bar(*xy, z=1):
x, y = xy
^
During: typing of exhaust iter at /Users/esc/git/numba-issues/numba/10258/10258.py (11)
File "numba/10258/10258.py", line 11:
def bar(*xy, z=1):
x, y = xy
^
During: Pass nopython_type_inference
Let me take a look at this