# Buggy code
def impl_new_list(item, allocated=0):
    """Creates a new list.

    Parameters
    ----------
    item: Numba type
        type of the list item.
    allocated: int
        number of items to pre-allocate

    """
    if not isinstance(item, Type):
        raise TypeError("expecting *item* to be a numba Type")

    itemty = item

    def imp(item, allocated=0):
        if allocated < 0:
            raise RuntimeError("expecting *allocated* to be >= 0")
        lp = _list_new(itemty, allocated)
        _list_set_method_table(lp, itemty)
        l = _make_list(itemty, lp)
        return l

    return imp


# Traceback (numba.errors.TypingError)
======================================================================
ERROR: test_numba_typed_list_allocated (sdc.tests.test_series.TestSeries)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\akozlov\AppData\Local\Continuum\anaconda3\hpat\sdc\tests\test_series.py
", line 6817, in test_numba_typed_list_allocated
print(jitted())
File "c:\users\akozlov\appdata\local\continuum\anaconda3\numba_master\numba\numba\disp
atcher.py", line 401, in _compile_for_args
error_rewrite(e, 'typing')
File "c:\users\akozlov\appdata\local\continuum\anaconda3\numba_master\numba\numba\disp
atcher.py", line 344, in error_rewrite
reraise(type(e), e, None)
File "c:\users\akozlov\appdata\local\continuum\anaconda3\numba_master\numba\numba\six.
py", line 668, in reraise
raise value.with_traceback(tb)
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function typedlist_empty at 0x0000015A9C481550>) with argument(
s) of type(s): (typeref[<class 'numba.types.containers.ListType'>], class(int64), int64)

* parameterized
In definition 0:
TypeError: typedlist_empty() takes 2 positional arguments but 3 were given
raised from c:\users\akozlov\appdata\local\continuum\anaconda3\numba_master\numba\nu
mba\typing\templates.py:539
In definition 1:
TypeError: typedlist_empty() takes 2 positional arguments but 3 were given
raised from c:\users\akozlov\appdata\local\continuum\anaconda3\numba_master\numba\nu
mba\typing\templates.py:539
This error is usually caused by passing an argument of a type that is unsupported by the
named function.
[1] During: resolving callee type: BoundFunction((<class 'numba.types.abstract.TypeRef'>
, 'empty_list') for typeref[<class 'numba.types.containers.ListType'>])
[2] During: typing of call at C:\Users\akozlov\AppData\Local\Continuum\anaconda3\hpat\sd
c\tests\test_series.py (6813)


File "sdc\tests\test_series.py", line 6813:
def test_impl():
<source elided>
# problem in overload of empty_list in typedlist.py
alloc_list = List.empty_list(types.int64, 10)
^


----------------------------------------------------------------------
Ran 1 test in 0.075s

FAILED (errors=1)

# Fixed code
def impl_new_list(item, allocated=DEFAULT_ALLOCATED):
    """Creates a new list.

    Parameters
    ----------
    item: Numba type
        type of the list item.
    allocated: int
        number of items to pre-allocate

    """
    if not isinstance(item, Type):
        raise TypeError("expecting *item* to be a numba Type")

    itemty = item

    def imp(item, allocated=DEFAULT_ALLOCATED):
        if allocated < 0:
            raise RuntimeError("expecting *allocated* to be >= 0")
        lp = _list_new(itemty, allocated)
        _list_set_method_table(lp, itemty)
        l = _make_list(itemty, lp)
        return l

    return imp