# Buggy code
def _get_incref_decref(context, module, datamodel, container_type):
    assert datamodel.contains_nrt_meminfo()

    fe_type = datamodel.fe_type
    data_ptr_ty = datamodel.get_data_type().as_pointer()
    refct_fnty = ir.FunctionType(ir.VoidType(), [data_ptr_ty])
    incref_fn = module.get_or_insert_function(
        refct_fnty,
        name=".numba_{}_incref${}".format(container_type, fe_type),
    )
    builder = ir.IRBuilder(incref_fn.append_basic_block())
    context.nrt.incref(builder, fe_type, builder.load(incref_fn.args[0]))
    builder.ret_void()

    decref_fn = module.get_or_insert_function(
        refct_fnty,
        name=".numba_{}_decref${}".format(container_type, fe_type),
    )
    builder = ir.IRBuilder(decref_fn.append_basic_block())
    context.nrt.decref(builder, fe_type, builder.load(decref_fn.args[0]))
    builder.ret_void()

    return incref_fn, decref_fn


# Traceback (TypingError)
TypingError                               Traceback (most recent call last)
<ipython-input-45-d29ae2daf2f2> in <module>
----> 1 l = numba.typed.List.empty_list(numba.typeof((0.0, "hello", True)))

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/typed/typedlist.py in empty_list(cls, item_type)
149         of the list .
150         """
--> 151         return cls(lsttype=ListType(item_type))
152
153     def __init__(self, **kwargs):

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/typed/typedlist.py in __init__(self, **kwargs)
164         """
165         if kwargs:
--> 166             self._list_type, self._opaque = self._parse_arg(**kwargs)
167         else:
168             self._list_type = None

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/typed/typedlist.py in _parse_arg(self, lsttype, meminfo)
175             opaque = meminfo
176         else:
--> 177             opaque = _make_list(lsttype.item_type)
178         return lsttype, opaque
179

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
374                 e.patch_message(msg)
375
--> 376             error_rewrite(e, 'typing')
377         except errors.UnsupportedError as e:
378             # Something unsupported is present in the user code, add help info

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/dispatcher.py in error_rewrite(e, issue_type)
341                 raise e
342             else:
--> 343                 reraise(type(e), e, None)
344
345         argtypes = []

/opt/anaconda/envs/test/lib/python3.7/site-packages/numba/six.py in reraise(tp, value, tb)
656             value = tp()
657         if value.__traceback__ is not tb:
--> 658             raise value.with_traceback(tb)
659         raise value
660


TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function new_list at 0x7f29d63d4510>) with argument(s) of type(s): (typeref[(unicode_type, bool)])
* parameterized
In definition 0:
LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
expecting {{i8*, i64, i32, i32, i64, i8*, i8*}, i1} but got {{i8*, i64, i32, i32, i64, i8*, i8*}, i8}

File "../../opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py", line 347:
def imp(item):
<source elided>
lp = _list_new(itemty)
_list_set_method_table(lp, itemty)
^

[1] During: lowering "$0.7 = call $0.4(lp, $0.6, func=$0.4, args=[Var(lp, /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (346)), Var($0.6, /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (347))], kws=(), vararg=None)" at /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (347)
raised from /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/six.py:659
In definition 1:
LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
expecting {{i8*, i64, i32, i32, i64, i8*, i8*}, i1} but got {{i8*, i64, i32, i32, i64, i8*, i8*}, i8}

File "../../opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py", line 347:
def imp(item):
<source elided>
lp = _list_new(itemty)
_list_set_method_table(lp, itemty)
^

[1] During: lowering "$0.7 = call $0.4(lp, $0.6, func=$0.4, args=[Var(lp, /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (346)), Var($0.6, /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (347))], kws=(), vararg=None)" at /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/listobject.py (347)
raised from /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/six.py:659
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<function new_list at 0x7f29d63d4510>)
[2] During: typing of call at /opt/anaconda/envs/test/lib/python3.7/site-packages/numba/typed/typedlist.py (29)

# Fixed code
def _get_incref_decref(context, module, datamodel, container_type):
    assert datamodel.contains_nrt_meminfo()

    fe_type = datamodel.fe_type
    data_ptr_ty = datamodel.get_data_type().as_pointer()
    refct_fnty = ir.FunctionType(ir.VoidType(), [data_ptr_ty])
    incref_fn = module.get_or_insert_function(
        refct_fnty,
        name=".numba_{}_incref${}".format(container_type, fe_type),
    )

    builder = ir.IRBuilder(incref_fn.append_basic_block())
    context.nrt.incref(
        builder,
        fe_type,
        datamodel.load_from_data_pointer(builder, incref_fn.args[0]),
    )
    builder.ret_void()

    decref_fn = module.get_or_insert_function(
        refct_fnty,
        name=".numba_{}_decref${}".format(container_type, fe_type),
    )
    builder = ir.IRBuilder(decref_fn.append_basic_block())
    context.nrt.decref(
        builder,
        fe_type,
        datamodel.load_from_data_pointer(builder, decref_fn.args[0]),
    )
    builder.ret_void()

    return incref_fn, decref_fn