# TypeError: Ambiguous overloading for \<function

**URL:** <https://numba.discourse.group/t/typeerror-ambiguous-overloading-for-function/2230>\
**Category:** Support: What is this error message?\
**Created:** [October 20, 2023, 5:23pm UTC](https://numba.discourse.group/t/typeerror-ambiguous-overloading-for-function/2230 "2023-10-20T17:23:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oyibo](https://avatars.discourse-cdn.com/v4/letter/o/4af34b/32.png) [@Oyibo](https://numba.discourse.group/u/Oyibo)\
**Post date:** [October 20, 2023, 5:23pm UTC](https://numba.discourse.group/t/typeerror-ambiguous-overloading-for-function/2230/1 "2023-10-20T17:23:08Z")

</div>

Hey Numba group,

I’ve encountered an issue related to function overloading using `FunctionType` with Numba version 0.58. There seems to be a problem if a jitted function has signatures which are identical except from the signature section of `FunctionType` itself.  
I’ve provided a simplified example to illustrate the problem.  
When I call `pfunc(func_1, arr)` or `pfunc(func_2, arr)`, I encounter the `TypeError: Ambiguous overloading` error.

```auto
import numpy as np
import numba as nb

@nb.njit('f8(f8[:])')
def func_1(arr):
    return np.sum(arr)

@nb.njit('f8[:](f8[:])')
def func_2(arr):
    return np.cumsum(arr)

@nb.njit(['f8[:](FunctionType(f8(f8[:])), f8[:])',
          'f8[:](FunctionType(f8[:](f8[:])), f8[:])'])
def pfunc(fn, arr):
    res = np.empty_like(arr)
    res[:] = fn(arr)
    return res

arr = np.arange(5.)
print(pfunc(func_1, arr))
print(pfunc(func_2, arr))
# TypeError: Ambiguous overloading for <function...

```

However, in my second version of the code, I separated the two signatures into two different functions, `pfunc_1` and `pfunc_2`, and after calling these functions once the issue disappears:

```auto
import numpy as np
import numba as nb

@nb.njit('f8(f8[:])')
def func_1(arr):
    return np.sum(arr)

@nb.njit('f8[:](f8[:])')
def func_2(arr):
    return np.cumsum(arr)

@nb.njit(['f8[:](FunctionType(f8(f8[:])), f8[:])'])
def pfunc_1(fn, arr):
    res = np.empty_like(arr)
    res[:] = fn(arr)
    return res

@nb.njit(['f8[:](FunctionType(f8[:](f8[:])), f8[:])'])
def pfunc_2(fn, arr):
    res = np.empty_like(arr)
    res[:] = fn(arr)
    return res

@nb.njit(['f8[:](FunctionType(f8(f8[:])), f8[:])',
          'f8[:](FunctionType(f8[:](f8[:])), f8[:])'])
def pfunc(fn, arr):
    res = np.empty_like(arr)
    res[:] = fn(arr)
    return res

arr = np.arange(5.)
print(pfunc_1(func_1, arr))
print(pfunc_2(func_2, arr))
print(pfunc(func_1, arr))
print(pfunc(func_2, arr))
# [10. 10. 10. 10. 10.]
# [0. 1. 3. 6. 10.]
# [10. 10. 10. 10. 10.]
# [0. 1. 3. 6. 10.]

```

My question is, why does Numba have difficulties resolving the function overloading in the first version, which contains a single `pfunc` function, and why does it work without errors in the second version after `pfunc_1` and `pfunc_2` has been called?  
An obvious workaround is to compile the base function into two or more functions and avoid having ambiguous signatures at all. Nevertheless, is there a way to use `FunctionType` in a single function without getting the “Ambiguous overloading” error?
