# Buggy code
def lower_assign(self, ty, inst):
    value = inst.value
    # In nopython mode, closure vars are frozen like globals
    if isinstance(value, (ir.Const, ir.Global, ir.FreeVar)):
        res = self.context.get_constant_generic(self.builder, ty, value.value)
        self.incref(ty, res)
        return res

    elif isinstance(value, ir.Expr):
        return self.lower_expr(ty, value)

    elif isinstance(value, ir.Var):
        val = self.loadvar(value.name)
        oty = self.typeof(value.name)
        res = self.context.cast(self.builder, val, oty, ty)
        self.incref(ty, res)
        return res

    elif isinstance(value, ir.Arg):
        # Cast from the argument type to the local variable type
        # (note the "arg.FOO" convention as used in typeinfer)
        argty = self.typeof("arg." + value.name)
        if isinstance(argty, types.Omitted):
            pyval = argty.value
            # use the type of the constant value
            valty = self.context.typing_context.resolve_value_type(pyval)
            const = self.context.get_constant_generic(self.builder, valty, pyval)
            # cast it to the variable type
            res = self.context.cast(self.builder, const, valty, ty)
        else:
            val = self.fnargs[value.index]
            res = self.context.cast(self.builder, val, argty, ty)
        self.incref(ty, res)
        return res

    elif isinstance(value, ir.Yield):
        res = self.lower_yield(ty, value)
        self.incref(ty, res)
        return res

    raise NotImplementedError(type(value), value)


# Traceback (numba.core.errors.TypingError)
Traceback (most recent call last):
File "./test.py", line 24, in <module>
f()
File ".../numba/core/dispatcher.py", line 401, in _compile_for_args
error_rewrite(e, 'typing')
File ".../numba/core/dispatcher.py", line 344, in error_rewrite
reraise(type(e), e, None)
File ".../numba/core/utils.py", line 79, in reraise
raise value.with_traceback(tb)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function my_func at 0x7ff222b79f70>) with argument(s) of type(s): ()
* parameterized
In definition 0:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function inner at 0x7ff23f0ab700>) with argument(s) of type(s): (unicode_type)
* parameterized
In definition 0:
All templates rejected with literals.
In definition 1:
All templates rejected without literals.
This error is usually caused by passing an argument of a type that is unsupported by the named function.

# Fixed code
def lower_assign(self, ty, inst):
    value = inst.value
    # In nopython mode, closure vars are frozen like globals
    if isinstance(value, (ir.Const, ir.Global, ir.FreeVar)):
        res = self.context.get_constant_generic(self.builder, ty, value.value)
        self.incref(ty, res)
        return res

    elif isinstance(value, ir.Expr):
        return self.lower_expr(ty, value)

    elif isinstance(value, ir.Var):
        val = self.loadvar(value.name)
        oty = self.typeof(value.name)
        res = self.context.cast(self.builder, val, oty, ty)
        self.incref(ty, res)
        return res

    elif isinstance(value, ir.Arg):
        # Cast from the argument type to the local variable type
        # (note the "arg.FOO" convention as used in typeinfer)
        argty = self.typeof("arg." + value.name)
        if isinstance(argty, types.Omitted):
            pyval = argty.value
            tyctx = self.context.typing_context
            valty = tyctx.resolve_value_type_prefer_literal(pyval)
            # use the type of the constant value
            const = self.context.get_constant_generic(
                self.builder,
                valty,
                pyval,
            )
            # cast it to the variable type
            res = self.context.cast(self.builder, const, valty, ty)
        else:
            val = self.fnargs[value.index]
            res = self.context.cast(self.builder, val, argty, ty)
        self.incref(ty, res)
        return res

    elif isinstance(value, ir.Yield):
        res = self.lower_yield(ty, value)
        self.incref(ty, res)
        return res

    raise NotImplementedError(type(value), value)