# Buggy code
def _do_work_getattr(self, state, work_list, block, i, expr):
    recv_type = state.type_annotation.typemap[expr.value.name]
    recv_type = types.unliteral(recv_type)
    matched = state.typingctx.find_matching_getattr_template(
        recv_type,
        expr.attr,
    )
    if not matched:
        return False
    template = matched["template"]
    if getattr(template, "is_method", False):
        # The attribute template is representing a method.
        # Don't inline the getattr.
        return False

    inline_type = getattr(template, "_inline", None)
    if inline_type is None:
        # inline not defined
        return False
    sig = typing.signature(matched["return_type"], recv_type)
    arg_typs = sig.args

    if not inline_type.is_never_inline:
        try:
            impl = template._overload_func(recv_type)
            if impl is None:
                raise Exception  # abort for this template
        except Exception:
            return False
    else:
        return False

    is_method = False
    return self._run_inliner(
        state,
        inline_type,
        sig,
        template,
        arg_typs,
        expr,
        i,
        impl,
        block,
        work_list,
        is_method,
    )


# Traceback (ValueError)
Traceback (most recent call last):
File "test_inline.py", line 14, in <module>
print(fn())
File "numba\numba\dispatcher.py", line 420, in _compile_for_args
raise e
File "numba\numba\dispatcher.py", line 353, in _compile_for_args
return self.compile(tuple(argtypes))
File "numba\numba\compiler_lock.py", line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File "numba\numba\dispatcher.py", line 768, in compile
cres = self._compiler.compile(args, return_type)
File "numba\numba\dispatcher.py", line 77, in compile
status, retval = self._compile_cached(args, return_type)
File "numba\numba\dispatcher.py", line 91, in _compile_cached
retval = self._compile_core(args, return_type)
File "numba\numba\dispatcher.py", line 109, in _compile_core
pipeline_class=self.pipeline_class)
File "numba\numba\compiler.py", line 551, in compile_extra
return pipeline.compile_extra(func)
File "numba\numba\compiler.py", line 331, in compile_extra
return self._compile_bytecode()
File "numba\numba\compiler.py", line 393, in _compile_bytecode
return self._compile_core()
File "numba\numba\compiler.py", line 373, in _compile_core
raise e
File "numba\numba\compiler.py", line 364, in _compile_core
pm.run(self.state)
File "numba\numba\compiler_machinery.py", line 347, in run
raise patched_exception
File "numba\numba\compiler_machinery.py", line 338, in run
self._runPass(idx, pass_inst, state)
File "numba\numba\compiler_lock.py", line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File "numba\numba\compiler_machinery.py", line 302, in _runPass
mutated |= check(pss.run_pass, internal_state)
File "numba\numba\compiler_machinery.py", line 275, in check
mangled = func(compiler_state)
File "numba\numba\untyped_passes.py", line 312, in run_pass
state.func_ir.blocks = simplify_CFG(state.func_ir.blocks)
File "numba\numba\ir_utils.py", line 1237, in simplify_CFG
return rename_labels(blocks)
File "numba\numba\ir_utils.py", line 1188, in rename_labels
topo_order.remove(return_label)
ValueError: Failed in nopython mode pipeline (step: inline inlinable functions)
list.remove(x): x not in list

# Fixed code
def _do_work_getattr(self, state, work_list, block, i, expr, inline_worker):
    recv_type = state.type_annotation.typemap[expr.value.name]
    recv_type = types.unliteral(recv_type)
    matched = state.typingctx.find_matching_getattr_template(
        recv_type,
        expr.attr,
    )
    if not matched:
        return False
    template = matched["template"]
    if getattr(template, "is_method", False):
        # The attribute template is representing a method.
        # Don't inline the getattr.
        return False

    inline_type = getattr(template, "_inline", None)
    if inline_type is None:
        # inline not defined
        return False
    sig = typing.signature(matched["return_type"], recv_type)
    arg_typs = sig.args

    if not inline_type.is_never_inline:
        try:
            impl = template._overload_func(recv_type)
            if impl is None:
                raise Exception  # abort for this template
        except Exception:
            return False
    else:
        return False

    is_method = False
    return self._run_inliner(
        state,
        inline_type,
        sig,
        template,
        arg_typs,
        expr,
        i,
        impl,
        block,
        work_list,
        is_method,
        inline_worker,
    )