# 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.swapped,
                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")


# Traceback (AssertionError)
Traceback (most recent call last):
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\errors.py", line 617, in new_error_context
yield
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\lowering.py", line 259, in lower_block
self.lower_inst(inst)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\pylowering.py", line 96, in lower_inst
value = self.lower_assign(inst)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\pylowering.py", line 186, in lower_assign
val = self.loadvar(value.name)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\pylowering.py", line 555, in loadvar
assert name in self._live_vars, name
AssertionError: array.22

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/yukoba/.IntelliJIdea2018.3/config/scratches/scratch_6.py", line 10, in <module>
print(main())
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\dispatcher.py", line 367, in _compile_for_args
raise e
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\dispatcher.py", line 324, in _compile_for_args
return self.compile(tuple(argtypes))
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler_lock.py", line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\dispatcher.py", line 655, in compile
cres = self._compiler.compile(args, return_type)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\dispatcher.py", line 82, in compile
pipeline_class=self.pipeline_class)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler.py", line 926, in compile_extra
return pipeline.compile_extra(func)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler.py", line 374, in compile_extra
return self._compile_bytecode()
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler.py", line 857, in _compile_bytecode
return self._compile_core()
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler.py", line 844, in _compile_core
res = pm.run(self.status)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler_lock.py", line 32, in _acquire_compile_lock
return func(*args, **kwargs)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler.py", line 255, in run
raise patched_exception
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler.py", line 246, in run
stage()
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler.py", line 691, in stage_objectmode_backend
self._backend(lowerfn, objectmode=True)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler.py", line 666, in _backend
lowered = lowerfn()
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler.py", line 638, in backend_object_mode
self.flags)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\compiler.py", line 1075, in py_lowering_stage
lower.lower()
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\lowering.py", line 178, in lower
self.lower_normal_function(self.fndesc)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\lowering.py", line 219, in lower_normal_function
entry_block_tail = self.lower_function_body()
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\lowering.py", line 244, in lower_function_body
self.lower_block(block)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\lowering.py", line 259, in lower_block
self.lower_inst(inst)
File "C:\Users\yukoba\Anaconda3\lib\contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\errors.py", line 625, in new_error_context
six.reraise(type(newerr), newerr, tb)
File "C:\Users\yukoba\Anaconda3\lib\site-packages\numba\six.py", line 659, in reraise
raise value
numba.errors.LoweringError: Failed in object mode pipeline (step: object mode backend)
array.22

File "scratch_6.py", line 7:
def main():
<source elided>
a = np.array(((1, 2), (3, 4)))
return np.array([x for x in a])
^

[1] During: lowering "$0.13 = array.22" at C:/Users/yukoba/.IntelliJIdea2018.3/config/scratches/scratch_6.py (7)

# 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.swapped,
                self.parallel_options.comprehension,
                self.typed,
            ):
                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")