# Buggy code
def run(self):
    """Run inline closure call pass."""
    modified = False
    work_list = list(self.func_ir.blocks.items())
    debug_print = _make_debug_print("InlineClosureCallPass")
    debug_print("START")
    while work_list:
        label, block = work_list.pop()
        for i, instr in enumerate(block.body):
            if isinstance(instr, ir.Assign):
                lhs = instr.target
                expr = instr.value
                if isinstance(expr, ir.Expr) and expr.op == "call":
                    call_name = guard(find_callname, self.func_ir, expr)
                    func_def = guard(get_definition, self.func_ir, expr.func)

                    if guard(
                        self._inline_reduction, work_list, block, i, expr, call_name
                    ):
                        modified = True
                        break  # because block structure changed

                    if guard(self._inline_closure, work_list, block, i, func_def):
                        modified = True
                        break  # because block structure changed

                    if guard(self._inline_stencil, instr, call_name, func_def):
                        modified = True

    if enable_inline_arraycall:
        # Identify loop structure
        if modified:
            # Need to do some cleanups if closure inlining kicked in
            merge_adjacent_blocks(self.func_ir.blocks)
        cfg = compute_cfg_from_blocks(self.func_ir.blocks)
        debug_print("start inline arraycall")
        _debug_dump(cfg)
        loops = cfg.loops()
        sized_loops = [(k, len(loops[k].body)) for k in loops.keys()]
        visited = []
        # We go over all loops, bigger loops first (outer first)
        for k, s in sorted(sized_loops, key=lambda tup: tup[1], reverse=True):
            visited.append(k)
            if guard(
                _inline_arraycall,
                self.func_ir,
                cfg,
                visited,
                loops[k],
                self.parallel_options.comprehension,
            ):
                modified = True
        if modified:
            _fix_nested_array(self.func_ir)

    if modified:
        remove_dels(self.func_ir.blocks)
        # repeat dead code elimintation until nothing can be further
        # removed
        while remove_dead(self.func_ir.blocks, self.func_ir.arg_names):
            pass
        self.func_ir.blocks = rename_labels(self.func_ir.blocks)
    debug_print("END")


# Traceback (LoweringError)
Serial:
[ 0  1  2  3  4 15 16 17 18 19]

Parallel:
Parallel for-loop #0 is produced from pattern '('prange', 'user')' at <ipython-input-1-f9ca7dd40116> (18)
After fusion, function parallel has 1 parallel for-loop(s) #set([0]).

---------------------------------------------------------------------------
LoweringError                             Traceback (most recent call last)
<ipython-input-1-f9ca7dd40116> in <module>()
27 print('\nParallel:')
28 A = np.arange(10)
---> 29 parallel(A)
30 print(A)

/home/lgarrison/anaconda2/lib/python2.7/site-packages/numba/dispatcher.pyc in _compile_for_args(self, *args, **kws)
358                     e.patch_message(''.join(e.args) + help_msg)
359             # ignore the FULL_TRACEBACKS config, this needs reporting!
--> 360             raise e
361
362     def inspect_llvm(self, signature=None):

LoweringError: Failed at nopython (nopython mode backend)
Failed at nopython (nopython mode backend)
expecting {{i8*, i8*, i64, i64, i64*, [1 x i64], [1 x i64]}, i64, i64*} but got i8*

File "<ipython-input-1-f9ca7dd40116>", line 18:
def parallel(A):
<source elided>
N = len(A)
for i in numba.prange(N):
^
[1] During: lowering "id=0[LoopNest(index_variable = parfor_index.2, range = (0, $N.4, 1))]{40: <ir.Block at <ipython-input-1-f9ca7dd40116> (18)>, 81: <ir.Block at <ipython-input-1-f9ca7dd40116> (18)>, 59: <ir.Block at <ipython-input-1-f9ca7dd40116> (19)>}Var(parfor_index.2, <ipython-input-1-f9ca7dd40116> (18))" at <ipython-input-1-f9ca7dd40116> (18)
-------------------------------------------------------------------------------
This should not have happened, a problem has occurred in Numba's internals.

Please report the error message and traceback, along with a minimal reproducer
at: https://github.com/numba/numba/issues/new

If you need help writing a minimal reproducer please see:
http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports

If more help is needed please feel free to speak to the Numba core developers
directly at: https://gitter.im/numba/numba

Thanks in advance for your help in improving Numba!

# Fixed code
def run(self):
    """Run inline closure call pass."""
    modified = False
    work_list = list(self.func_ir.blocks.items())
    debug_print = _make_debug_print("InlineClosureCallPass")
    debug_print("START")
    while work_list:
        label, block = work_list.pop()
        for i, instr in enumerate(block.body):
            if isinstance(instr, ir.Assign):
                lhs = instr.target
                expr = instr.value
                if isinstance(expr, ir.Expr) and expr.op == "call":
                    call_name = guard(find_callname, self.func_ir, expr)
                    func_def = guard(get_definition, self.func_ir, expr.func)

                    if guard(
                        self._inline_reduction, work_list, block, i, expr, call_name
                    ):
                        modified = True
                        break  # because block structure changed

                    if guard(self._inline_closure, work_list, block, i, func_def):
                        modified = True
                        break  # because block structure changed

                    if guard(self._inline_stencil, instr, call_name, func_def):
                        modified = True

    if enable_inline_arraycall:
        # Identify loop structure
        if modified:
            # Need to do some cleanups if closure inlining kicked in
            merge_adjacent_blocks(self.func_ir.blocks)
        cfg = compute_cfg_from_blocks(self.func_ir.blocks)
        debug_print("start inline arraycall")
        _debug_dump(cfg)
        loops = cfg.loops()
        sized_loops = [(k, len(loops[k].body)) for k in loops.keys()]
        visited = []
        # We go over all loops, bigger loops first (outer first)
        for k, s in sorted(sized_loops, key=lambda tup: tup[1], reverse=True):
            visited.append(k)
            if guard(
                _inline_arraycall,
                self.func_ir,
                cfg,
                visited,
                loops[k],
                self.parallel_options.comprehension,
            ):
                modified = True
        if modified:
            _fix_nested_array(self.func_ir)

    if modified:
        remove_dels(self.func_ir.blocks)
        # repeat dead code elimintation until nothing can be further
        # removed
        while remove_dead(self.func_ir.blocks, self.func_ir.arg_names, self.func_ir):
            pass
        self.func_ir.blocks = rename_labels(self.func_ir.blocks)
    debug_print("END")