# Buggy code
def unified_function_type(numba_types, require_precise=True):
    """Returns a unified Numba function type if possible.

    Parameters
    ----------
    numba_types : tuple
      Numba type instances.
    require_precise : bool
      If True, the returned Numba function type must be precise.

    Returns
    -------
    typ : {numba.core.types.Type, None}
      A unified Numba function type. Or ``None`` when the Numba types
      cannot be unified, e.g. when the ``numba_types`` contains at
      least two different Numba function type instances.

    If ``numba_types`` contains a Numba dispatcher type, the unified
    Numba function type will be an imprecise ``UndefinedFunctionType``
    instance, or None when ``require_precise=True`` is specified.

    Specifying ``require_precise=False`` enables unifying imprecise
    Numba dispatcher instances when used in tuples or if-then branches
    when the precise Numba function cannot be determined on the first
    occurrence that is not a call expression.
    """
    from numba.core.errors import NumbaExperimentalFeatureWarning

    if not (
        numba_types
        and isinstance(numba_types[0], (types.Dispatcher, types.FunctionType))
    ):
        return

    warnings.warn(
        "First-class function type feature is experimental",
        category=NumbaExperimentalFeatureWarning,
    )

    mnargs, mxargs = None, None
    dispatchers = set()
    function = None
    undefined_function = None

    for t in numba_types:
        if isinstance(t, types.Dispatcher):
            mnargs1, mxargs1 = get_nargs_range(t.dispatcher.py_func)
            if mnargs is None:
                mnargs, mxargs = mnargs1, mxargs1
            elif not (mnargs, mxargs) == (mnargs1, mxargs1):
                return
            dispatchers.add(t.dispatcher)
            t = t.dispatcher.get_function_type()
            if t is None:
                continue
        if isinstance(t, types.FunctionType):
            if mnargs is None:
                mnargs = mxargs = t.nargs
            elif not (mnargs == mxargs == t.nargs):
                return numba_types
            if isinstance(t, types.UndefinedFunctionType):
                if undefined_function is None:
                    undefined_function = t
                else:
                    # Refuse to unify using function type
                    return
                dispatchers.update(t.dispatchers)
            else:
                if function is None:
                    function = t
                else:
                    assert function == t
        else:
            return
    if require_precise and (function is None or undefined_function is not None):
        return
    if function is not None:
        if undefined_function is not None:
            assert function.nargs == undefined_function.nargs
            function = undefined_function
    elif undefined_function is not None:
        undefined_function.dispatchers.update(dispatchers)
        function = undefined_function
    else:
        function = types.UndefinedFunctionType(mnargs, dispatchers)

    return function


# Traceback (TypeError)
Traceback (most recent call last):
File "/home/lucio/mypyprojects/numba/numba/core/errors.py", line 726, in new_error_context
yield
File "/home/lucio/mypyprojects/numba/numba/core/lowering.py", line 267, in lower_block
self.lower_inst(inst)
File "/home/lucio/mypyprojects/numba/numba/core/lowering.py", line 364, in lower_inst
val = self.lower_assign(ty, inst)
File "/home/lucio/mypyprojects/numba/numba/core/lowering.py", line 538, in lower_assign
return self.lower_expr(ty, value)
File "/home/lucio/mypyprojects/numba/numba/core/lowering.py", line 1194, in lower_expr
self.loadvar(expr.index.name)))
File "/home/lucio/mypyprojects/numba/numba/core/base.py", line 1155, in __call__
res = self._imp(self._context, builder, self._sig, args, loc=loc)
File "/home/lucio/mypyprojects/numba/numba/core/base.py", line 1185, in wrapper
return fn(*args, **kwargs)
File "/home/lucio/mypyprojects/numba/numba/cpython/tupleobj.py", line 254, in getitem_typed
sig.return_type) == sig.return_type
File "/home/lucio/mypyprojects/numba/numba/core/typing/context.py", line 630, in unify_types
unified = self.unify_pairs(unified, tp)
File "/home/lucio/mypyprojects/numba/numba/core/typing/context.py", line 649, in unify_pairs
unified = first.unify(self, second)
File "/home/lucio/mypyprojects/numba/numba/core/types/containers.py", line 320, in unify
print(Tuple(unified))
File "/home/lucio/mypyprojects/numba/numba/core/types/abstract.py", line 65, in __call__
inst = type.__call__(cls, *args, **kwargs)
File "/home/lucio/mypyprojects/numba/numba/core/types/containers.py", line 283, in __new__
return UniTuple(dtype=t, count=len(types))
File "/home/lucio/mypyprojects/numba/numba/core/types/abstract.py", line 66, in __call__
return cls._intern(inst)
File "/home/lucio/mypyprojects/numba/numba/core/types/abstract.py", line 50, in _intern
orig = _typecache.get(wr)
File "/home/lucio/mypyprojects/numba/numba/core/types/abstract.py", line 118, in __hash__
return hash(self.key)
TypeError: unhashable type: 'list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/lucio/.PyCharm2018.3/config/scratches/numba unification problem.py", line 37, in <module>
baz(np.zeros((5, 10)), funcs)
File "/home/lucio/mypyprojects/numba/numba/core/dispatcher.py", line 420, in _compile_for_args
raise e
File "/home/lucio/mypyprojects/numba/numba/core/dispatcher.py", line 353, in _compile_for_args
return self.compile(tuple(argtypes))
File "/home/lucio/mypyprojects/numba/numba/core/compiler_lock.py", line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File "/home/lucio/mypyprojects/numba/numba/core/dispatcher.py", line 794, in compile
cres = self._compiler.compile(args, return_type)
File "/home/lucio/mypyprojects/numba/numba/core/dispatcher.py", line 77, in compile
status, retval = self._compile_cached(args, return_type)
File "/home/lucio/mypyprojects/numba/numba/core/dispatcher.py", line 91, in _compile_cached
retval = self._compile_core(args, return_type)
File "/home/lucio/mypyprojects/numba/numba/core/dispatcher.py", line 109, in _compile_core
pipeline_class=self.pipeline_class)
File "/home/lucio/mypyprojects/numba/numba/core/compiler.py", line 568, in compile_extra
return pipeline.compile_extra(func)
File "/home/lucio/mypyprojects/numba/numba/core/compiler.py", line 339, in compile_extra
return self._compile_bytecode()
File "/home/lucio/mypyprojects/numba/numba/core/compiler.py", line 401, in _compile_bytecode
return self._compile_core()
File "/home/lucio/mypyprojects/numba/numba/core/compiler.py", line 381, in _compile_core
raise e
File "/home/lucio/mypyprojects/numba/numba/core/compiler.py", line 372, in _compile_core
pm.run(self.state)
File "/home/lucio/mypyprojects/numba/numba/core/compiler_machinery.py", line 341, in run
raise patched_exception
File "/home/lucio/mypyprojects/numba/numba/core/compiler_machinery.py", line 332, in run
self._runPass(idx, pass_inst, state)
File "/home/lucio/mypyprojects/numba/numba/core/compiler_lock.py", line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File "/home/lucio/mypyprojects/numba/numba/core/compiler_machinery.py", line 291, in _runPass
mutated |= check(pss.run_pass, internal_state)
File "/home/lucio/mypyprojects/numba/numba/core/compiler_machinery.py", line 264, in check
mangled = func(compiler_state)
File "/home/lucio/mypyprojects/numba/numba/core/typed_passes.py", line 442, in run_pass
NativeLowering().run_pass(state)
File "/home/lucio/mypyprojects/numba/numba/core/typed_passes.py", line 370, in run_pass
lower.lower()
File "/home/lucio/mypyprojects/numba/numba/core/lowering.py", line 179, in lower
self.lower_normal_function(self.fndesc)
File "/home/lucio/mypyprojects/numba/numba/core/lowering.py", line 227, in lower_normal_function
entry_block_tail = self.lower_function_body()
File "/home/lucio/mypyprojects/numba/numba/core/lowering.py", line 253, in lower_function_body
self.lower_block(block)
File "/home/lucio/mypyprojects/numba/numba/core/lowering.py", line 267, in lower_block
self.lower_inst(inst)
File "/home/lucio/anaconda3/envs/numbaenv/lib/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "/home/lucio/mypyprojects/numba/numba/core/errors.py", line 733, in new_error_context
reraise(type(newerr), newerr, tb)
File "/home/lucio/mypyprojects/numba/numba/core/utils.py", line 81, in reraise
raise value
numba.core.errors.LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
unhashable type: 'list'

File "numba unification problem.py", line 30:
def baz(a, funcs):
<source elided>
idx = 0
for i in literal_unroll(funcs):
^

[1] During: lowering "i.33 = typed_getitem(value=$8.3, dtype=Tuple(type(CPUDispatcher(<function foo1 at 0x7f11868ccea0>)), type(CPUDispatcher(<function bar1 at 0x7f11740aaae8>))), index=$phi18.1)" at /home/lucio/.PyCharm2018.3/config/scratches/numba unification problem.py (30)

# Fixed code
def unified_function_type(numba_types, require_precise=True):
    """Returns a unified Numba function type if possible.

    Parameters
    ----------
    numba_types : tuple
      Numba type instances.
    require_precise : bool
      If True, the returned Numba function type must be precise.

    Returns
    -------
    typ : {numba.core.types.Type, None}
      A unified Numba function type. Or ``None`` when the Numba types
      cannot be unified, e.g. when the ``numba_types`` contains at
      least two different Numba function type instances.

    If ``numba_types`` contains a Numba dispatcher type, the unified
    Numba function type will be an imprecise ``UndefinedFunctionType``
    instance, or None when ``require_precise=True`` is specified.

    Specifying ``require_precise=False`` enables unifying imprecise
    Numba dispatcher instances when used in tuples or if-then branches
    when the precise Numba function cannot be determined on the first
    occurrence that is not a call expression.
    """
    from numba.core.errors import NumbaExperimentalFeatureWarning

    if not (
        numba_types
        and isinstance(numba_types[0], (types.Dispatcher, types.FunctionType))
    ):
        return

    warnings.warn(
        "First-class function type feature is experimental",
        category=NumbaExperimentalFeatureWarning,
    )

    mnargs, mxargs = None, None
    dispatchers = set()
    function = None
    undefined_function = None

    for t in numba_types:
        if isinstance(t, types.Dispatcher):
            mnargs1, mxargs1 = get_nargs_range(t.dispatcher.py_func)
            if mnargs is None:
                mnargs, mxargs = mnargs1, mxargs1
            elif not (mnargs, mxargs) == (mnargs1, mxargs1):
                return
            dispatchers.add(t.dispatcher)
            t = t.dispatcher.get_function_type()
            if t is None:
                continue
        if isinstance(t, types.FunctionType):
            if mnargs is None:
                mnargs = mxargs = t.nargs
            elif not (mnargs == mxargs == t.nargs):
                return
            if isinstance(t, types.UndefinedFunctionType):
                if undefined_function is None:
                    undefined_function = t
                else:
                    # Refuse to unify using function type
                    return
                dispatchers.update(t.dispatchers)
            else:
                if function is None:
                    function = t
                else:
                    assert function == t
        else:
            return
    if require_precise and (function is None or undefined_function is not None):
        return
    if function is not None:
        if undefined_function is not None:
            assert function.nargs == undefined_function.nargs
            function = undefined_function
    elif undefined_function is not None:
        undefined_function.dispatchers.update(dispatchers)
        function = undefined_function
    else:
        function = types.UndefinedFunctionType(mnargs, dispatchers)

    return function