# Buggy code
def _expand_callable_macro(self, interp, call, macro, loc):
    """
    Return the IR expression of expanding the macro call.
    """
    assert macro.callable

    # Resolve all macro arguments as constants, or fail
    args = [interp.infer_constant(arg.name) for arg in call.args]
    kws = {}
    for k, v in call.kws:
        try:
            kws[k] = interp.infer_constant(v)
        except errors.ConstantInferenceError:
            msg = "Argument {name!r} must be a constant at {loc}".format(
                name=k, loc=loc
            )
            raise ValueError(msg)

    try:
        result = macro.func(*args, **kws)
    except Exception as e:
        msg = str(e)
        headfmt = "Macro expansion failed at {line}"
        head = headfmt.format(line=loc)
        newmsg = "{0}:\n{1}".format(head, msg)
        raise errors.MacroError(newmsg)

    assert result is not None

    result.loc = call.loc
    new_expr = ir.Expr.call(func=result, args=call.args, kws=call.kws, loc=loc)
    return new_expr


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-3b23f7331ceb> in <module>()
----> 1 @jit(arg_types=[numba.double], ret_type=numba.double)
2 def is_REALLY_five(some_value):
3     for i in range(5):
4         if some_value == 5.0:
5             return 1.0

/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/numba/decorators.pyc in _jit(func)
77                   "garbage collected!" % (func,))
78         t = Translate(func, *args, **kws)
---> 79         t.translate()
80         __tr_map__[func] = t
81         return t.get_ctypes_func(llvm)

/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/numba/translate.pyc in translate(self)
926                     # Ensure we are playing with locals that might
927                     # actually precede the next block.
--> 928                     self.check_locals(i)
929
930                 self.crnt_block = i

/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/numba/translate.pyc in check_locals(self, i)
1135                 else:
1136                     assert next_locals is not None, "Internal compiler error!"
-> 1137             self._locals = next_locals[:]
1138
1139     def get_ctypes_func(self, llvm=True):

TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def _expand_callable_macro(self, func_ir, call, macro, loc):
    """
    Return the IR expression of expanding the macro call.
    """
    assert macro.callable

    # Resolve all macro arguments as constants, or fail
    args = [func_ir.infer_constant(arg.name) for arg in call.args]
    kws = {}
    for k, v in call.kws:
        try:
            kws[k] = func_ir.infer_constant(v)
        except errors.ConstantInferenceError:
            msg = "Argument {name!r} must be a constant at {loc}".format(
                name=k, loc=loc
            )
            raise ValueError(msg)

    try:
        result = macro.func(*args, **kws)
    except Exception as e:
        msg = str(e)
        headfmt = "Macro expansion failed at {line}"
        head = headfmt.format(line=loc)
        newmsg = "{0}:\n{1}".format(head, msg)
        raise errors.MacroError(newmsg)

    assert result is not None

    result.loc = call.loc
    new_expr = ir.Expr.call(func=result, args=call.args, kws=call.kws, loc=loc)
    return new_expr