Overload not properly producing omitted types
See original GitHub issueReporting a bug
- I have tried using the latest released version of Numba (most recent is visible in the change log (https://github.com/numba/numba/blob/main/CHANGE_LOG).
- I have included a self contained code sample to reproduce the problem. i.e. it’s possible to run as ‘python bug.py’.
It seems like the compilation path for overloads doesn’t properly do argument folding and therefore doesn’t produce omitted types. Here is a reproducer:
from numba.extending import overload
from numba import njit
def foo(a, b=1):
pass
@overload(foo)
def foo_overload(a, b=1):
print(a, b)
def foo_impl(a, b=1):
return a + b
return foo_impl
@njit
def g(a):
return foo(a)
g(100)
On master this outputs:
int64 1
So b is a python literal 1, not an omitted type.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:8 (7 by maintainers)
Top Results From Across the Web
8.11 — Function overload resolution and ambiguous matches
If an overloaded function is not properly differentiated from the other overloads of the same name, then the compiler will issue a compile ......
Read more >Wrong generic overload function called - Stack Overflow
The type of the method to be called is selected during compile time. What does the compiler know about your types?
Read more >select overload not match when enable strict mode in tsconfig
When I turn off strictFunctionTypes everything work well. ... to select the state with selector have created it appear overload not match.
Read more >Overload resolution - cppreference.com
If at least one of the arguments to an operator in an expression has a class type or an enumeration type, both builtin...
Read more >Operator Overloading, C++ FAQ - Standard C++
What operators can/cannot be overloaded? Why can't I overload . (dot), :: , sizeof , etc.? Can I define my ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This seems to be possible to convert to a literal type if you reuse the argument folding used by dispatchers. Here is a diff that outputs
int64 omitted(default=1)Of course the python signature should probably be computed only once. Is there any reason this isn’t an omitted type right now? It seems like if there was ever a default value that was unhashable then it wouldn’t be possible to cache the overload.
@njriasan as noted in the Numba meeting, the follow doesn’t actually solve any of this but might help some use cases: