Repository: numba/numba

Issue:
Numba internal error during lowering

Minimal reproducible example:

```python
import numpy as np, pandas as pd
import numba

@numba.jit
def clifford_trajectory(a, b, c, d, x0, y0, n):
    xs, ys = np.zeros(n), np.zeros(n)
    xs[0], ys[0] = x0, y0
    for i in np.arange(n-1):
        xs[i+1] = np.sin(a * ys[i]) + c * np.cos(a * xs[i])
        ys[i+1] = np.sin(b * xs[i]) + d * np.cos(b * ys[i])
    return pd.DataFrame(dict(x=xs,y=ys))

clifford_trajectory(a=1.7, b=1.7, c=0.6, d=1.2, x0=0, y0=0, n=2000000)
```

Originally triggered in the context of this [anaconda-project](https://anaconda.org/jbednar/project/Attractors).

## Traceback:

<details>
<pre>
<ipython-input-1-58f41f58473f>:4: NumbaWarning: 
Compilation is falling back to object mode WITH looplifting enabled because Function "clifford_trajectory" failed type inference due to: Unknown attribute 'DataFrame' of type Module(<module 'pandas' from '/opt/continuum/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/pandas/__init__.py'>)

File "<ipython-input-1-58f41f58473f>", line 11:
def clifford_trajectory(a, b, c, d, x0, y0, n):
    <source elided>
        ys[i+1] = np.sin(b * xs[i]) + d * np.cos(b * ys[i])
    return pd.DataFrame(dict(x=xs,y=ys))
    ^

[1] During: typing of get attribute at <ipython-input-1-58f41f58473f> (11)

File "<ipython-input-1-58f41f58473f>", line 11:
def clifford_trajectory(a, b, c, d, x0, y0, n):
    <source elided>
        ys[i+1] = np.sin(b * xs[i]) + d * np.cos(b * ys[i])
    return pd.DataFrame(dict(x=xs,y=ys))
    ^

  @jit
<ipython-input-1-58f41f58473f>:4: NumbaWarning: 
Compilation is falling back to object mode WITHOUT looplifting enabled because Function "clifford_trajectory" failed type inference due to: cannot determine Numba type of <class 'numba.dispatcher.LiftedLoop'>

File "<ipython-input-1-58f41f58473f>", line 8:
def clifford_trajectory(a, b, c, d, x0, y0, n):
    <source elided>
    xs[0], ys[0] = x0, y0
    for i in np.arange(n-1):
    ^

  @jit
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
    660     try:
--> 661         yield
    662     except NumbaError as e:

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/lowering.py in lower_block(self, block)
    257                                    loc=self.loc, errcls_=defaulterrcls):
--> 258                 self.lower_inst(inst)
    259 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/pylowering.py in lower_inst(self, inst)
    175         else:
--> 176             raise NotImplementedError(type(inst), inst)
    177 

NotImplementedError: (<class 'numba.ir.StaticSetItem'>, xs[0] = x0)

During handling of the above exception, another exception occurred:

LoweringError                             Traceback (most recent call last)
<ipython-input-1-58f41f58473f> in <module>()
     11     return pd.DataFrame(dict(x=xs,y=ys))
     12 
---> 13 clifford_trajectory(a=1.7, b=1.7, c=0.6, d=1.2, x0=0, y0=0, n=2000000)

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
    368                     e.patch_message(''.join(e.args) + help_msg)
    369             # ignore the FULL_TRACEBACKS config, this needs reporting!
--> 370             raise e
    371 
    372     def inspect_llvm(self, signature=None):

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
    325                 argtypes.append(self.typeof_pyval(a))
    326         try:
--> 327             return self.compile(tuple(argtypes))
    328         except errors.TypingError as e:
    329             # Intercept typing error that may be due to an argument

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
     30         def _acquire_compile_lock(*args, **kwargs):
     31             with self:
---> 32                 return func(*args, **kwargs)
     33         return _acquire_compile_lock
     34 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/dispatcher.py in compile(self, sig)
    657 
    658             self._cache_misses[sig] += 1
--> 659             cres = self._compiler.compile(args, return_type)
    660             self.add_overload(cres)
    661             self._cache.save_overload(sig, cres)

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/dispatcher.py in compile(self, args, return_type)
     81                                       args=args, return_type=return_type,
     82                                       flags=flags, locals=self.locals,
---> 83                                       pipeline_class=self.pipeline_class)
     84         # Check typing error if object mode is used
     85         if cres.typing_error is not None and not flags.enable_pyobject:

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
    953     pipeline = pipeline_class(typingctx, targetctx, library,
    954                               args, return_type, flags, locals)
--> 955     return pipeline.compile_extra(func)
    956 
    957 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in compile_extra(self, func)
    375         self.lifted = ()
    376         self.lifted_from = None
--> 377         return self._compile_bytecode()
    378 
    379     def compile_ir(self, func_ir, lifted=(), lifted_from=None):

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in _compile_bytecode(self)
    884         """
    885         assert self.func_ir is None
--> 886         return self._compile_core()
    887 
    888     def _compile_ir(self):

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in _compile_core(self)
    871         self.define_pipelines(pm)
    872         pm.finalize()
--> 873         res = pm.run(self.status)
    874         if res is not None:
    875             # Early pipeline completion

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
     30         def _acquire_compile_lock(*args, **kwargs):
     31             with self:
---> 32                 return func(*args, **kwargs)
     33         return _acquire_compile_lock
     34 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in run(self, status)
    252                     # No more fallback pipelines?
    253                     if is_final_pipeline:
--> 254                         raise patched_exception
    255                     # Go to next fallback pipeline
    256                     else:

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in run(self, status)
    243                 try:
    244                     event("-- %s" % stage_name)
--> 245                     stage()
    246                 except _EarlyPipelineCompletion as e:
    247                     return e.result

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in stage_objectmode_frontend(self)
    461         if self.flags.enable_looplift:
    462             assert not self.lifted
--> 463             cres = self.frontend_looplift()
    464             if cres is not None:
    465                 raise _EarlyPipelineCompletion(cres)

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in frontend_looplift(self)
    433                               self.args, self.return_type,
    434                               outer_flags, self.locals,
--> 435                               lifted=tuple(loops), lifted_from=None)
    436             return cres
    437 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in compile_ir(typingctx, targetctx, func_ir, args, return_type, flags, locals, lifted, lifted_from, is_lifted_loop, library, pipeline_class)
   1015                                   args, return_type, flags, locals)
   1016         return pipeline.compile_ir(func_ir=func_ir, lifted=lifted,
-> 1017                                 lifted_from=lifted_from)
   1018 
   1019 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in compile_ir(self, func_ir, lifted, lifted_from)
    383 
    384         self._set_and_check_ir(func_ir)
--> 385         return self._compile_ir()
    386 
    387     def stage_analyze_bytecode(self):

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in _compile_ir(self)
    891         """
    892         assert self.func_ir is not None
--> 893         return self._compile_core()
    894 
    895 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in _compile_core(self)
    871         self.define_pipelines(pm)
    872         pm.finalize()
--> 873         res = pm.run(self.status)
    874         if res is not None:
    875             # Early pipeline completion

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
     30         def _acquire_compile_lock(*args, **kwargs):
     31             with self:
---> 32                 return func(*args, **kwargs)
     33         return _acquire_compile_lock
     34 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in run(self, status)
    252                     # No more fallback pipelines?
    253                     if is_final_pipeline:
--> 254                         raise patched_exception
    255                     # Go to next fallback pipeline
    256                     else:

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in run(self, status)
    243                 try:
    244                     event("-- %s" % stage_name)
--> 245                     stage()
    246                 except _EarlyPipelineCompletion as e:
    247                     return e.result

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in stage_objectmode_backend(self)
    709         """
    710         lowerfn = self.backend_object_mode
--> 711         self._backend(lowerfn, objectmode=True)
    712 
    713         # Warn, deprecated behaviour, code compiled in objmode without

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in _backend(self, lowerfn, objectmode)
    685             self.library.enable_object_caching()
    686 
--> 687         lowered = lowerfn()
    688         signature = typing.signature(self.return_type, *self.args)
    689         self.cr = compile_result(

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in backend_object_mode(self)
    657                                      self.library,
    658                                      self.func_ir,
--> 659                                      self.flags)
    660 
    661     def backend_nopython_mode(self):

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in py_lowering_stage(targetctx, library, interp, flags)
   1146     with targetctx.push_code_library(library):
   1147         lower = pylowering.PyLower(targetctx, library, fndesc, interp)
-> 1148         lower.lower()
   1149         if not flags.no_cpython_wrapper:
   1150             lower.create_cpython_wrapper()

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/lowering.py in lower(self)
    175         if self.generator_info is None:
    176             self.genlower = None
--> 177             self.lower_normal_function(self.fndesc)
    178         else:
    179             self.genlower = self.GeneratorLower(self)

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/lowering.py in lower_normal_function(self, fndesc)
    216         # Init argument values
    217         self.extract_function_arguments()
--> 218         entry_block_tail = self.lower_function_body()
    219 
    220         # Close tail of entry block

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/lowering.py in lower_function_body(self)
    241             bb = self.blkmap[offset]
    242             self.builder.position_at_end(bb)
--> 243             self.lower_block(block)
    244 
    245         self.post_lower()

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/lowering.py in lower_block(self, block)
    256             with new_error_context('lowering "{inst}" at {loc}', inst=inst,
    257                                    loc=self.loc, errcls_=defaulterrcls):
--> 258                 self.lower_inst(inst)
    259 
    260     def create_cpython_wrapper(self, release_gil=False):

~/anaconda/envs/anaconda50_py36/lib/python3.6/contextlib.py in __exit__(self, type, value, traceback)
     97                 value = type()
     98             try:
---> 99                 self.gen.throw(type, value, traceback)
    100             except StopIteration as exc:
    101                 # Suppress StopIteration *unless* it's the same exception that

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
    667         from numba import config
    668         tb = sys.exc_info()[2] if config.FULL_TRACEBACKS else None
--> 669         six.reraise(type(newerr), newerr, tb)
    670 
    671 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/six.py in reraise(tp, value, tb)
    657         if value.__traceback__ is not tb:
    658             raise value.with_traceback(tb)
--> 659         raise value
    660 
    661 else:

LoweringError: Failed in object mode pipeline (step: object mode frontend)
Failed in object mode pipeline (step: object mode backend)
(<class 'numba.ir.StaticSetItem'>, xs[0] = x0)

File "<ipython-input-1-58f41f58473f>", line 7:
def clifford_trajectory(a, b, c, d, x0, y0, n):
    <source elided>
    xs, ys = np.zeros(n), np.zeros(n)
    xs[0], ys[0] = x0, y0
    ^

[1] During: lowering "xs[0] = x0" at <ipython-input-1-58f41f58473f> (7)
-------------------------------------------------------------------------------
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 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!
</pre>
</details>

## Versions

```python
>>> np.__version__, pd.__version__, numba.__version__
('1.13.3', '0.22.0', '0.44.1')
```
Numba internal error during lowering

Minimal reproducible example:

```python
import numpy as np, pandas as pd
import numba

@numba.jit
def clifford_trajectory(a, b, c, d, x0, y0, n):
    xs, ys = np.zeros(n), np.zeros(n)
    xs[0], ys[0] = x0, y0
    for i in np.arange(n-1):
        xs[i+1] = np.sin(a * ys[i]) + c * np.cos(a * xs[i])
        ys[i+1] = np.sin(b * xs[i]) + d * np.cos(b * ys[i])
    return pd.DataFrame(dict(x=xs,y=ys))

clifford_trajectory(a=1.7, b=1.7, c=0.6, d=1.2, x0=0, y0=0, n=2000000)
```

Originally triggered in the context of this [anaconda-project](https://anaconda.org/jbednar/project/Attractors).

## Traceback:

<details>
<pre>
<ipython-input-1-58f41f58473f>:4: NumbaWarning: 
Compilation is falling back to object mode WITH looplifting enabled because Function "clifford_trajectory" failed type inference due to: Unknown attribute 'DataFrame' of type Module(<module 'pandas' from '/opt/continuum/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/pandas/__init__.py'>)

File "<ipython-input-1-58f41f58473f>", line 11:
def clifford_trajectory(a, b, c, d, x0, y0, n):
    <source elided>
        ys[i+1] = np.sin(b * xs[i]) + d * np.cos(b * ys[i])
    return pd.DataFrame(dict(x=xs,y=ys))
    ^

[1] During: typing of get attribute at <ipython-input-1-58f41f58473f> (11)

File "<ipython-input-1-58f41f58473f>", line 11:
def clifford_trajectory(a, b, c, d, x0, y0, n):
    <source elided>
        ys[i+1] = np.sin(b * xs[i]) + d * np.cos(b * ys[i])
    return pd.DataFrame(dict(x=xs,y=ys))
    ^

  @jit
<ipython-input-1-58f41f58473f>:4: NumbaWarning: 
Compilation is falling back to object mode WITHOUT looplifting enabled because Function "clifford_trajectory" failed type inference due to: cannot determine Numba type of <class 'numba.dispatcher.LiftedLoop'>

File "<ipython-input-1-58f41f58473f>", line 8:
def clifford_trajectory(a, b, c, d, x0, y0, n):
    <source elided>
    xs[0], ys[0] = x0, y0
    for i in np.arange(n-1):
    ^

  @jit
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
    660     try:
--> 661         yield
    662     except NumbaError as e:

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/lowering.py in lower_block(self, block)
    257                                    loc=self.loc, errcls_=defaulterrcls):
--> 258                 self.lower_inst(inst)
    259 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/pylowering.py in lower_inst(self, inst)
    175         else:
--> 176             raise NotImplementedError(type(inst), inst)
    177 

NotImplementedError: (<class 'numba.ir.StaticSetItem'>, xs[0] = x0)

During handling of the above exception, another exception occurred:

LoweringError                             Traceback (most recent call last)
<ipython-input-1-58f41f58473f> in <module>()
     11     return pd.DataFrame(dict(x=xs,y=ys))
     12 
---> 13 clifford_trajectory(a=1.7, b=1.7, c=0.6, d=1.2, x0=0, y0=0, n=2000000)

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
    368                     e.patch_message(''.join(e.args) + help_msg)
    369             # ignore the FULL_TRACEBACKS config, this needs reporting!
--> 370             raise e
    371 
    372     def inspect_llvm(self, signature=None):

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
    325                 argtypes.append(self.typeof_pyval(a))
    326         try:
--> 327             return self.compile(tuple(argtypes))
    328         except errors.TypingError as e:
    329             # Intercept typing error that may be due to an argument

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
     30         def _acquire_compile_lock(*args, **kwargs):
     31             with self:
---> 32                 return func(*args, **kwargs)
     33         return _acquire_compile_lock
     34 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/dispatcher.py in compile(self, sig)
    657 
    658             self._cache_misses[sig] += 1
--> 659             cres = self._compiler.compile(args, return_type)
    660             self.add_overload(cres)
    661             self._cache.save_overload(sig, cres)

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/dispatcher.py in compile(self, args, return_type)
     81                                       args=args, return_type=return_type,
     82                                       flags=flags, locals=self.locals,
---> 83                                       pipeline_class=self.pipeline_class)
     84         # Check typing error if object mode is used
     85         if cres.typing_error is not None and not flags.enable_pyobject:

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
    953     pipeline = pipeline_class(typingctx, targetctx, library,
    954                               args, return_type, flags, locals)
--> 955     return pipeline.compile_extra(func)
    956 
    957 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in compile_extra(self, func)
    375         self.lifted = ()
    376         self.lifted_from = None
--> 377         return self._compile_bytecode()
    378 
    379     def compile_ir(self, func_ir, lifted=(), lifted_from=None):

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in _compile_bytecode(self)
    884         """
    885         assert self.func_ir is None
--> 886         return self._compile_core()
    887 
    888     def _compile_ir(self):

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in _compile_core(self)
    871         self.define_pipelines(pm)
    872         pm.finalize()
--> 873         res = pm.run(self.status)
    874         if res is not None:
    875             # Early pipeline completion

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
     30         def _acquire_compile_lock(*args, **kwargs):
     31             with self:
---> 32                 return func(*args, **kwargs)
     33         return _acquire_compile_lock
     34 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in run(self, status)
    252                     # No more fallback pipelines?
    253                     if is_final_pipeline:
--> 254                         raise patched_exception
    255                     # Go to next fallback pipeline
    256                     else:

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in run(self, status)
    243                 try:
    244                     event("-- %s" % stage_name)
--> 245                     stage()
    246                 except _EarlyPipelineCompletion as e:
    247                     return e.result

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in stage_objectmode_frontend(self)
    461         if self.flags.enable_looplift:
    462             assert not self.lifted
--> 463             cres = self.frontend_looplift()
    464             if cres is not None:
    465                 raise _EarlyPipelineCompletion(cres)

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in frontend_looplift(self)
    433                               self.args, self.return_type,
    434                               outer_flags, self.locals,
--> 435                               lifted=tuple(loops), lifted_from=None)
    436             return cres
    437 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in compile_ir(typingctx, targetctx, func_ir, args, return_type, flags, locals, lifted, lifted_from, is_lifted_loop, library, pipeline_class)
   1015                                   args, return_type, flags, locals)
   1016         return pipeline.compile_ir(func_ir=func_ir, lifted=lifted,
-> 1017                                 lifted_from=lifted_from)
   1018 
   1019 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in compile_ir(self, func_ir, lifted, lifted_from)
    383 
    384         self._set_and_check_ir(func_ir)
--> 385         return self._compile_ir()
    386 
    387     def stage_analyze_bytecode(self):

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in _compile_ir(self)
    891         """
    892         assert self.func_ir is not None
--> 893         return self._compile_core()
    894 
    895 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in _compile_core(self)
    871         self.define_pipelines(pm)
    872         pm.finalize()
--> 873         res = pm.run(self.status)
    874         if res is not None:
    875             # Early pipeline completion

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
     30         def _acquire_compile_lock(*args, **kwargs):
     31             with self:
---> 32                 return func(*args, **kwargs)
     33         return _acquire_compile_lock
     34 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in run(self, status)
    252                     # No more fallback pipelines?
    253                     if is_final_pipeline:
--> 254                         raise patched_exception
    255                     # Go to next fallback pipeline
    256                     else:

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in run(self, status)
    243                 try:
    244                     event("-- %s" % stage_name)
--> 245                     stage()
    246                 except _EarlyPipelineCompletion as e:
    247                     return e.result

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in stage_objectmode_backend(self)
    709         """
    710         lowerfn = self.backend_object_mode
--> 711         self._backend(lowerfn, objectmode=True)
    712 
    713         # Warn, deprecated behaviour, code compiled in objmode without

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in _backend(self, lowerfn, objectmode)
    685             self.library.enable_object_caching()
    686 
--> 687         lowered = lowerfn()
    688         signature = typing.signature(self.return_type, *self.args)
    689         self.cr = compile_result(

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in backend_object_mode(self)
    657                                      self.library,
    658                                      self.func_ir,
--> 659                                      self.flags)
    660 
    661     def backend_nopython_mode(self):

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/compiler.py in py_lowering_stage(targetctx, library, interp, flags)
   1146     with targetctx.push_code_library(library):
   1147         lower = pylowering.PyLower(targetctx, library, fndesc, interp)
-> 1148         lower.lower()
   1149         if not flags.no_cpython_wrapper:
   1150             lower.create_cpython_wrapper()

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/lowering.py in lower(self)
    175         if self.generator_info is None:
    176             self.genlower = None
--> 177             self.lower_normal_function(self.fndesc)
    178         else:
    179             self.genlower = self.GeneratorLower(self)

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/lowering.py in lower_normal_function(self, fndesc)
    216         # Init argument values
    217         self.extract_function_arguments()
--> 218         entry_block_tail = self.lower_function_body()
    219 
    220         # Close tail of entry block

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/lowering.py in lower_function_body(self)
    241             bb = self.blkmap[offset]
    242             self.builder.position_at_end(bb)
--> 243             self.lower_block(block)
    244 
    245         self.post_lower()

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/lowering.py in lower_block(self, block)
    256             with new_error_context('lowering "{inst}" at {loc}', inst=inst,
    257                                    loc=self.loc, errcls_=defaulterrcls):
--> 258                 self.lower_inst(inst)
    259 
    260     def create_cpython_wrapper(self, release_gil=False):

~/anaconda/envs/anaconda50_py36/lib/python3.6/contextlib.py in __exit__(self, type, value, traceback)
     97                 value = type()
     98             try:
---> 99                 self.gen.throw(type, value, traceback)
    100             except StopIteration as exc:
    101                 # Suppress StopIteration *unless* it's the same exception that

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/errors.py in new_error_context(fmt_, *args, **kwargs)
    667         from numba import config
    668         tb = sys.exc_info()[2] if config.FULL_TRACEBACKS else None
--> 669         six.reraise(type(newerr), newerr, tb)
    670 
    671 

~/anaconda/envs/anaconda50_py36/lib/python3.6/site-packages/numba/six.py in reraise(tp, value, tb)
    657         if value.__traceback__ is not tb:
    658             raise value.with_traceback(tb)
--> 659         raise value
    660 
    661 else:

LoweringError: Failed in object mode pipeline (step: object mode frontend)
Failed in object mode pipeline (step: object mode backend)
(<class 'numba.ir.StaticSetItem'>, xs[0] = x0)

File "<ipython-input-1-58f41f58473f>", line 7:
def clifford_trajectory(a, b, c, d, x0, y0, n):
    <source elided>
    xs, ys = np.zeros(n), np.zeros(n)
    xs[0], ys[0] = x0, y0
    ^

[1] During: lowering "xs[0] = x0" at <ipython-input-1-58f41f58473f> (7)
-------------------------------------------------------------------------------
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 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!
</pre>
</details>

## Versions

```python
>>> np.__version__, pd.__version__, numba.__version__
('1.13.3', '0.22.0', '0.44.1')
```


Discussion:
I just did a git bisect.  It is caused by 91b31734809b2cca6864cc56e9a17dccc37c4c89 from https://github.com/numba/numba/pull/3884.
I just did a git bisect.  It is caused by 91b31734809b2cca6864cc56e9a17dccc37c4c89 from https://github.com/numba/numba/pull/3884.

Resolving patch:
diff --git a/numba/compiler.py b/numba/compiler.py
--- a/numba/compiler.py
+++ b/numba/compiler.py
@@ -432,7 +432,8 @@ def frontend_looplift(self):
             cres = compile_ir(self.typingctx, self.targetctx, main,
                               self.args, self.return_type,
                               outer_flags, self.locals,
-                              lifted=tuple(loops), lifted_from=None)
+                              lifted=tuple(loops), lifted_from=None,
+                              is_lifted_loop=True)
             return cres
 
     def stage_frontend_withlift(self):
@@ -997,11 +998,13 @@ def compile_local(the_ir, the_flags):
         # that's usable from above.
         rw_cres = None
         if not flags.no_rewrites:
-            try:
-                rw_cres = compile_local(func_ir.copy(), flags)
-            except Exception:
-                pass
-
+            # Suppress warnings in compilation retry
+            with warnings.catch_warnings():
+                warnings.simplefilter("ignore", errors.NumbaWarning)
+                try:
+                    rw_cres = compile_local(func_ir.copy(), flags)
+                except Exception:
+                    pass
         # if the rewrite variant of compilation worked, use it, else use
         # the norewrites backup
         if rw_cres is not None:


Test patch:
diff --git a/numba/tests/test_looplifting.py b/numba/tests/test_looplifting.py
--- a/numba/tests/test_looplifting.py
+++ b/numba/tests/test_looplifting.py
@@ -557,5 +557,27 @@ def foo(X):
         f(1)
         self.assertEqual(len(f.overloads[f.signatures[0]].lifted), 1)
 
+    def test_lift_objectmode_issue_4223(self):
+        from numba import jit
+
+        @jit
+        def foo(a, b, c, d, x0, y0, n):
+            xs, ys = np.zeros(n), np.zeros(n)
+            xs[0], ys[0] = x0, y0
+            for i in np.arange(n-1):
+                xs[i+1] = np.sin(a * ys[i]) + c * np.cos(a * xs[i])
+                ys[i+1] = np.sin(b * xs[i]) + d * np.cos(b * ys[i])
+            object() # ensure object mode
+            return xs, ys
+
+        kwargs = dict(a=1.7, b=1.7, c=0.6, d=1.2, x0=0, y0=0, n=200)
+        got = foo(**kwargs)
+        expected = foo.py_func(**kwargs)
+        self.assertPreciseEqual(got[0], expected[0])
+        self .assertPreciseEqual(got[1], expected[1])
+        [lifted] = foo.overloads[foo.signatures[0]].lifted
+        self.assertEqual(len(lifted.nopython_signatures), 1)
+
+
 if __name__ == '__main__':
     unittest.main()