# Buggy code
def __init__(self, typingctx, targetctx, library, args, return_type, flags, locals):
    # Make sure the environment is reloaded
    config.reload_config()
    typingctx.refresh()
    targetctx.refresh()

    self.typingctx = typingctx
    self.targetctx = _make_subtarget(targetctx, flags)
    self.library = library
    self.args = args
    self.return_type = return_type
    self.flags = flags
    self.locals = locals

    # Results of various steps of the compilation pipeline
    self.bc = None
    self.func_id = None
    self.func_ir = None
    self.lifted = None
    self.lifted_from = None
    self.typemap = None
    self.calltypes = None
    self.type_annotation = None

    self.status = _CompileStatus(
        can_fallback=self.flags.enable_pyobject, can_giveup=config.COMPATIBILITY_MODE
    )


# Traceback (NotImplementedError)
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
242     try:
--> 243         yield
244     except NumbaError as e:

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/lowering.py in lower_block(self, block)
200                                    loc=self.loc, errcls_=defaulterrcls):
--> 201                 self.lower_inst(inst)
202

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/objmode.py in lower_inst(self, inst)
144         else:
--> 145             raise NotImplementedError(type(inst), inst)
146

NotImplementedError: (<class 'numba.ir.StaticSetItem'>, a2[0] = $const0.5)

During handling of the above exception, another exception occurred:

LoweringError                             Traceback (most recent call last)
<ipython-input-1-0cabfcdeff6e> in <module>()
12     return s
13
---> 14 test(np.array([3]), np.array([4]))

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
284                 argtypes.append(self.typeof_pyval(a))
285         try:
--> 286             return self.compile(tuple(argtypes))
287         except errors.TypingError as e:
288             # Intercept typing error that may be due to an argument

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/dispatcher.py in compile(self, sig)
530
531             self._cache_misses[sig] += 1
--> 532             cres = self._compiler.compile(args, return_type)
533             self.add_overload(cres)
534             self._cache.save_overload(sig, cres)

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/dispatcher.py in compile(self, args, return_type)
79                                       impl,
80                                       args=args, return_type=return_type,
---> 81                                       flags=flags, locals=self.locals)
82         # Check typing error if object mode is used
83         if cres.typing_error is not None and not flags.enable_pyobject:

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library)
682     pipeline = Pipeline(typingctx, targetctx, library,
683                         args, return_type, flags, locals)
--> 684     return pipeline.compile_extra(func)
685
686

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in compile_extra(self, func)
346         self.lifted = ()
347         self.lifted_from = None
--> 348         return self._compile_bytecode()
349
350     def compile_ir(self, func_ir, lifted=(), lifted_from=None):

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in _compile_bytecode(self)
647         """
648         assert self.func_ir is None
--> 649         return self._compile_core()
650
651     def _compile_ir(self):

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in _compile_core(self)
634
635         pm.finalize()
--> 636         res = pm.run(self.status)
637         if res is not None:
638             # Early pipeline completion

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in run(self, status)
233                     # No more fallback pipelines?
234                     if is_final_pipeline:
--> 235                         raise patched_exception
236                     # Go to next fallback pipeline
237                     else:

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in run(self, status)
225                 try:
226                     event(stage_name)
--> 227                     stage()
228                 except _EarlyPipelineCompletion as e:
229                     return e.result

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in stage_objectmode_frontend(self)
413         if self.flags.enable_looplift:
414             assert not self.lifted
--> 415             cres = self.frontend_looplift()
416             if cres is not None:
417                 raise _EarlyPipelineCompletion(cres)

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in frontend_looplift(self)
404                               self.args, self.return_type,
405                               outer_flags, self.locals,
--> 406                               lifted=tuple(loops), lifted_from=None)
407             return cres
408

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in compile_ir(typingctx, targetctx, func_ir, args, return_type, flags, locals, lifted, lifted_from, library)
696                         args, return_type, flags, locals)
697     return pipeline.compile_ir(func_ir=func_ir, lifted=lifted,
--> 698                                lifted_from=lifted_from)
699
700

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in compile_ir(self, func_ir, lifted, lifted_from)
354
355         self._set_and_check_ir(func_ir)
--> 356         return self._compile_ir()
357
358     def stage_analyze_bytecode(self):

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in _compile_ir(self)
654         """
655         assert self.func_ir is not None
--> 656         return self._compile_core()
657
658

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in _compile_core(self)
634
635         pm.finalize()
--> 636         res = pm.run(self.status)
637         if res is not None:
638             # Early pipeline completion

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in run(self, status)
233                     # No more fallback pipelines?
234                     if is_final_pipeline:
--> 235                         raise patched_exception
236                     # Go to next fallback pipeline
237                     else:

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in run(self, status)
225                 try:
226                     event(stage_name)
--> 227                     stage()
228                 except _EarlyPipelineCompletion as e:
229                     return e.result

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in stage_objectmode_backend(self)
552         """
553         lowerfn = self.backend_object_mode
--> 554         self._backend(lowerfn, objectmode=True)
555
556         # Warn if compiled function in object mode and force_pyobject not set

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in _backend(self, lowerfn, objectmode)
529             self.library.enable_object_caching()
530
--> 531         lowered = lowerfn()
532         signature = typing.signature(self.return_type, *self.args)
533         self.cr = compile_result(typing_context=self.typingctx,

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in backend_object_mode(self)
503                                      self.library,
504                                      self.func_ir,
--> 505                                      self.flags)
506
507     def backend_nopython_mode(self):

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/compiler.py in py_lowering_stage(targetctx, library, interp, flags)
824     fndesc = funcdesc.PythonFunctionDescriptor.from_object_mode_function(interp)
825     lower = objmode.PyLower(targetctx, library, fndesc, interp)
--> 826     lower.lower()
827     if not flags.no_cpython_wrapper:
828         lower.create_cpython_wrapper()

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/lowering.py in lower(self)
124         if self.generator_info is None:
125             self.genlower = None
--> 126             self.lower_normal_function(self.fndesc)
127         else:
128             self.genlower = self.GeneratorLower(self)

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/lowering.py in lower_normal_function(self, fndesc)
159         # Init argument values
160         self.extract_function_arguments()
--> 161         entry_block_tail = self.lower_function_body()
162
163         # Close tail of entry block

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/lowering.py in lower_function_body(self)
184             bb = self.blkmap[offset]
185             self.builder.position_at_end(bb)
--> 186             self.lower_block(block)
187
188         self.post_lower()

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/lowering.py in lower_block(self, block)
199             with new_error_context('lowering "{inst}" at {loc}', inst=inst,
200                                    loc=self.loc, errcls_=defaulterrcls):
--> 201                 self.lower_inst(inst)
202
203     def create_cpython_wrapper(self, release_gil=False):

/Applications/anaconda/envs/numba029/lib/python3.5/contextlib.py in __exit__(self, type, value, traceback)
75                 value = type()
76             try:
---> 77                 self.gen.throw(type, value, traceback)
78                 raise RuntimeError("generator didn't stop after throw()")
79             except StopIteration as exc:

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
247     except Exception as e:
248         newerr = errcls(e).add_context(_format_msg(fmt_, args, kwargs))
--> 249         six.reraise(type(newerr), newerr, sys.exc_info()[2])
250
251

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/six.py in reraise(tp, value, tb)
656             value = tp()
657         if value.__traceback__ is not tb:
--> 658             raise value.with_traceback(tb)
659         raise value
660

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
241     errcls = kwargs.pop('errcls_', InternalError)
242     try:
--> 243         yield
244     except NumbaError as e:
245         e.add_context(_format_msg(fmt_, args, kwargs))

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/lowering.py in lower_block(self, block)
199             with new_error_context('lowering "{inst}" at {loc}', inst=inst,
200                                    loc=self.loc, errcls_=defaulterrcls):
--> 201                 self.lower_inst(inst)
202
203     def create_cpython_wrapper(self, release_gil=False):

/Applications/anaconda/envs/numba029/lib/python3.5/site-packages/numba/objmode.py in lower_inst(self, inst)
143
144         else:
--> 145             raise NotImplementedError(type(inst), inst)
146
147     def lower_assign(self, inst):

LoweringError: Failed at object (object mode frontend)
Failed at object (object mode backend)
(<class 'numba.ir.StaticSetItem'>, a2[0] = $const0.5)
File "<ipython-input-1-0cabfcdeff6e>", line 7
[1] During: lowering "a2[0] = $const0.5" at <ipython-input-1-0cabfcdeff6e> (7)

# Fixed code
def __init__(self, typingctx, targetctx, library, args, return_type, flags, locals):
    # Make sure the environment is reloaded
    config.reload_config()
    typingctx.refresh()
    targetctx.refresh()

    self.typingctx = typingctx
    self.targetctx = _make_subtarget(targetctx, flags)
    self.library = library
    self.args = args
    self.return_type = return_type
    self.flags = flags
    self.locals = locals

    # Results of various steps of the compilation pipeline
    self.bc = None
    self.func_id = None
    self.func_ir = None
    self.func_ir_original = None  # used for fallback
    self.lifted = None
    self.lifted_from = None
    self.typemap = None
    self.calltypes = None
    self.type_annotation = None

    self.status = _CompileStatus(
        can_fallback=self.flags.enable_pyobject, can_giveup=config.COMPATIBILITY_MODE
    )