# Buggy code
def apply(self, kind, pipeline, interp):
    """Given a pipeline and a dictionary of basic blocks, exhaustively
    attempt to apply all registered rewrites to all basic blocks.
    """
    assert kind in self._kinds
    blocks = interp.blocks
    old_blocks = blocks.copy()
    for rewrite_cls in self.rewrites[kind]:
        # Exhaustively apply a rewrite until it stops matching.
        rewrite = rewrite_cls(pipeline)
        work_list = list(blocks.items())
        while work_list:
            key, block = work_list.pop()
            matches = rewrite.match(interp, block, pipeline.typemap, pipeline.calltypes)
            if matches:
                if config.DEBUG or config.DUMP_IR:
                    print("_" * 70)
                    print("REWRITING (%s):" % rewrite_cls.__name__)
                    block.dump()
                    print("_" * 60)
                new_block = rewrite.apply()
                blocks[key] = new_block
                work_list.append((key, new_block))
                if config.DEBUG or config.DUMP_IR:
                    new_block.dump()
                    print("_" * 70)
    # If any blocks were changed, perform a sanity check.
    for key, block in blocks.items():
        if block != old_blocks[key]:
            block.verify()


# 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 apply(self, kind, pipeline, func_ir):
    """Given a pipeline and a dictionary of basic blocks, exhaustively
    attempt to apply all registered rewrites to all basic blocks.
    """
    assert kind in self._kinds
    blocks = func_ir.blocks
    old_blocks = blocks.copy()
    for rewrite_cls in self.rewrites[kind]:
        # Exhaustively apply a rewrite until it stops matching.
        rewrite = rewrite_cls(pipeline)
        work_list = list(blocks.items())
        while work_list:
            key, block = work_list.pop()
            matches = rewrite.match(
                func_ir, block, pipeline.typemap, pipeline.calltypes
            )
            if matches:
                if config.DEBUG or config.DUMP_IR:
                    print("_" * 70)
                    print("REWRITING (%s):" % rewrite_cls.__name__)
                    block.dump()
                    print("_" * 60)
                new_block = rewrite.apply()
                blocks[key] = new_block
                work_list.append((key, new_block))
                if config.DEBUG or config.DUMP_IR:
                    new_block.dump()
                    print("_" * 70)
    # If any blocks were changed, perform a sanity check.
    for key, block in blocks.items():
        if block != old_blocks[key]:
            block.verify()