# Buggy code
def unify_types(self, *typelist):
    # Sort the type list according to bit width before doing
    # pairwise unification (with thanks to aterrel).
    def keyfunc(obj):
        """Uses bitwidth to order numeric-types.
        Fallback to hash() for arbitary ordering.
        """
        return getattr(obj, "bitwidth", hash(obj))

    typelist = sorted(typelist, key=keyfunc)
    unified = typelist[0]
    for tp in typelist[1:]:
        unified = self.unify_pairs(unified, tp)
        if unified is None:
            break
    return unified


# Traceback (AssertionError)
def f(): return [True]
...
ff = jit(nopython=True)(f)
ff()
Traceback (most recent call last):
File "/home/antoine/numba/numba/lowering.py", line 173, in lower_block
self.lower_inst(inst)
File "/home/antoine/numba/numba/lowering.py", line 215, in lower_inst
val = self.lower_assign(ty, inst)
File "/home/antoine/numba/numba/lowering.py", line 371, in lower_assign
return self.lower_expr(ty, value)
File "/home/antoine/numba/numba/lowering.py", line 733, in lower_expr
return self.context.build_list(self.builder, resty, castvals)
File "/home/antoine/numba/numba/targets/cpu.py", line 111, in build_list
return listobj.build_list(self, builder, list_type, items)
File "/home/antoine/numba/numba/targets/listobj.py", line 301, in build_list
inst = ListInstance.allocate(context, builder, list_type, nitems)
File "/home/antoine/numba/numba/targets/listobj.py", line 190, in allocate
self._payload.allocated = nitems
File "/home/antoine/numba/numba/targets/listobj.py", line 154, in _payload
return get_list_payload(self._context, self._builder, self._ty, self._list)
File "/home/antoine/numba/numba/targets/listobj.py", line 44, in get_list_payload
return make_payload_cls(list_type)(context, builder, ref=payload)
File "/home/antoine/numba/numba/cgutils.py", line 95, in __init__
% (self._be_type.as_pointer(), ref.type))
AssertionError: bad ref type: expected {i64, i64, i1}*, got {i64, i64, i8}*

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/antoine/numba/numba/dispatcher.py", line 162, in _compile_for_args
return self.compile(sig)
File "/home/antoine/numba/numba/dispatcher.py", line 327, in compile
flags=flags, locals=self.locals)
File "/home/antoine/numba/numba/compiler.py", line 594, in compile_extra
return pipeline.compile_extra(func)
File "/home/antoine/numba/numba/compiler.py", line 317, in compile_extra
return self.compile_bytecode(bc, func_attr=self.func_attr)
File "/home/antoine/numba/numba/compiler.py", line 326, in compile_bytecode
return self._compile_bytecode()
File "/home/antoine/numba/numba/compiler.py", line 581, in _compile_bytecode
return pm.run(self.status)
File "/home/antoine/numba/numba/compiler.py", line 209, in run
raise patched_exception
File "/home/antoine/numba/numba/compiler.py", line 201, in run
res = stage()
File "/home/antoine/numba/numba/compiler.py", line 537, in stage_nopython_backend
return self._backend(lowerfn, objectmode=False)
File "/home/antoine/numba/numba/compiler.py", line 492, in _backend
lowered = lowerfn()
File "/home/antoine/numba/numba/compiler.py", line 483, in backend_nopython_mode
self.flags)
File "/home/antoine/numba/numba/compiler.py", line 723, in native_lowering_stage
lower.lower()
File "/home/antoine/numba/numba/lowering.py", line 100, in lower
self.lower_normal_function(self.fndesc)
File "/home/antoine/numba/numba/lowering.py", line 135, in lower_normal_function
entry_block_tail = self.lower_function_body()
File "/home/antoine/numba/numba/lowering.py", line 160, in lower_function_body
self.lower_block(block)
File "/home/antoine/numba/numba/lowering.py", line 178, in lower_block
raise LoweringError(msg, inst.loc)
numba.errors.LoweringError: Failed at nopython (nopython mode backend)
Internal error:
AssertionError: bad ref type: expected {i64, i64, i1}*, got {i64, i64, i8}*
File "<stdin>", line 1

# Fixed code
def unify_types(self, *typelist):
    # Sort the type list according to bit width before doing
    # pairwise unification (with thanks to aterrel).
    def keyfunc(obj):
        """Uses bitwidth to order numeric-types.
        Fallback to stable, deterministic sort.
        """
        return getattr(obj, "bitwidth", 0)

    typelist = sorted(typelist, key=keyfunc)
    unified = typelist[0]
    for tp in typelist[1:]:
        unified = self.unify_pairs(unified, tp)
        if unified is None:
            break
    return unified