# Buggy code
def generic(self, args, kws):
    # Redirect resolution to __init__
    instance_type = self.key.instance_type
    ctor = instance_type.jitmethods["__init__"]
    boundargs = (instance_type.get_reference_type(),) + args
    disp_type = types.Dispatcher(ctor)
    sig = disp_type.get_call_type(self.context, boundargs, kws)
    # Actual constructor returns an instance value (not None)
    out = templates.signature(instance_type, *sig.args[1:])
    return out


# Traceback (AssertionError)
---------------------------------------------------------------------------

AssertionError                            Traceback (most recent call last)

c:\program files\python36-64\lib\site-packages\numba\errors.py in new_error_context(fmt_, *args, **kwargs)
716     try:
--> 717         yield
718     except NumbaError as e:

c:\program files\python36-64\lib\site-packages\numba\lowering.py in lower_block(self, block)
259                                    loc=self.loc, errcls_=defaulterrcls):
--> 260                 self.lower_inst(inst)
261

c:\program files\python36-64\lib\site-packages\numba\lowering.py in lower_inst(self, inst)
302             ty = self.typeof(inst.target.name)
--> 303             val = self.lower_assign(ty, inst)
304             self.storevar(val, inst.target.name)

c:\program files\python36-64\lib\site-packages\numba\lowering.py in lower_assign(self, ty, inst)
464         elif isinstance(value, ir.Expr):
--> 465             return self.lower_expr(ty, value)
466

c:\program files\python36-64\lib\site-packages\numba\lowering.py in lower_expr(self, resty, expr)
926         elif expr.op == 'call':
--> 927             res = self.lower_call(resty, expr)
928             return res

c:\program files\python36-64\lib\site-packages\numba\lowering.py in lower_call(self, resty, expr)
718         else:
--> 719             res = self._lower_call_normal(fnty, expr, signature)
720

c:\program files\python36-64\lib\site-packages\numba\lowering.py in _lower_call_normal(self, fnty, expr, signature)
897
--> 898         res = impl(self.builder, argvals, self.loc)
899         return res

c:\program files\python36-64\lib\site-packages\numba\targets\base.py in __call__(self, builder, args, loc)
1131     def __call__(self, builder, args, loc=None):
-> 1132         res = self._imp(self._context, builder, self._sig, args, loc=loc)
1133         self._context.add_linking_libs(getattr(self, 'libs', ()))

c:\program files\python36-64\lib\site-packages\numba\targets\base.py in wrapper(*args, **kwargs)
1156             kwargs.pop('loc')     # drop unused loc
-> 1157             return fn(*args, **kwargs)
1158

c:\program files\python36-64\lib\site-packages\numba\jitclass\base.py in ctor_impl(context, builder, sig, args)
522     realargs = [inst_struct._getvalue()] + list(args)
--> 523     call(builder, realargs)
524

c:\program files\python36-64\lib\site-packages\numba\targets\base.py in __call__(self, builder, args, loc)
1131     def __call__(self, builder, args, loc=None):
-> 1132         res = self._imp(self._context, builder, self._sig, args, loc=loc)
1133         self._context.add_linking_libs(getattr(self, 'libs', ()))

c:\program files\python36-64\lib\site-packages\numba\targets\base.py in wrapper(*args, **kwargs)
1156             kwargs.pop('loc')     # drop unused loc
-> 1157             return fn(*args, **kwargs)
1158

c:\program files\python36-64\lib\site-packages\numba\targets\imputils.py in imp(context, builder, sig, args)
195             context.call_conv.return_status_propagate(builder, status)
--> 196         assert sig.return_type == fndesc.restype
197         # Reconstruct optional return type

AssertionError:


During handling of the above exception, another exception occurred:

LoweringError                             Traceback (most recent call last)

<ipython-input-60-3e6844f03bc2> in <module>
2 start=np.zeros(2,dtype=np.int32)
3 end=np.zeros(2,dtype=np.int32)+2
----> 4 LineVectorIntegral(start,end,fields)
5

c:\program files\python36-64\lib\site-packages\numba\jitclass\base.py in __call__(cls, *args, **kwargs)
124         bind = cls._ctor_sig.bind(None, *args, **kwargs)
125         bind.apply_defaults()
--> 126         return cls._ctor(*bind.args[1:], **bind.kwargs)
127
128

c:\program files\python36-64\lib\site-packages\numba\dispatcher.py in _compile_for_args(self, *args, **kws)
418                     e.patch_message('\n'.join((str(e).rstrip(), help_msg)))
419             # ignore the FULL_TRACEBACKS config, this needs reporting!
--> 420             raise e
421
422     def inspect_llvm(self, signature=None):

c:\program files\python36-64\lib\site-packages\numba\dispatcher.py in _compile_for_args(self, *args, **kws)
351                 argtypes.append(self.typeof_pyval(a))
352         try:
--> 353             return self.compile(tuple(argtypes))
354         except errors.ForceLiteralArg as e:
355             # Received request for compiler re-entry with the list of arguments

c:\program files\python36-64\lib\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

c:\program files\python36-64\lib\site-packages\numba\dispatcher.py in compile(self, sig)
766             self._cache_misses[sig] += 1
767             try:
--> 768                 cres = self._compiler.compile(args, return_type)
769             except errors.ForceLiteralArg as e:
770                 def folded(args, kws):

c:\program files\python36-64\lib\site-packages\numba\dispatcher.py in compile(self, args, return_type)
75
76     def compile(self, args, return_type):
---> 77         status, retval = self._compile_cached(args, return_type)
78         if status:
79             return retval

c:\program files\python36-64\lib\site-packages\numba\dispatcher.py in _compile_cached(self, args, return_type)
89
90         try:
---> 91             retval = self._compile_core(args, return_type)
92         except errors.TypingError as e:
93             self._failed_cache[key] = e

c:\program files\python36-64\lib\site-packages\numba\dispatcher.py in _compile_core(self, args, return_type)
107                                       args=args, return_type=return_type,
108                                       flags=flags, locals=self.locals,
--> 109                                       pipeline_class=self.pipeline_class)
110         # Check typing error if object mode is used
111         if cres.typing_error is not None and not flags.enable_pyobject:

c:\program files\python36-64\lib\site-packages\numba\compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
526     pipeline = pipeline_class(typingctx, targetctx, library,
527                               args, return_type, flags, locals)
--> 528     return pipeline.compile_extra(func)
529
530

c:\program files\python36-64\lib\site-packages\numba\compiler.py in compile_extra(self, func)
324         self.state.lifted = ()
325         self.state.lifted_from = None
--> 326         return self._compile_bytecode()
327
328     def compile_ir(self, func_ir, lifted=(), lifted_from=None):

c:\program files\python36-64\lib\site-packages\numba\compiler.py in _compile_bytecode(self)
383         """
384         assert self.state.func_ir is None
--> 385         return self._compile_core()
386
387     def _compile_ir(self):

c:\program files\python36-64\lib\site-packages\numba\compiler.py in _compile_core(self)
363                 self.state.status.fail_reason = e
364                 if is_final_pipeline:
--> 365                     raise e
366         else:
367             raise CompilerError("All available pipelines exhausted")

c:\program files\python36-64\lib\site-packages\numba\compiler.py in _compile_core(self)
354             res = None
355             try:
--> 356                 pm.run(self.state)
357                 if self.state.cr is not None:
358                     break

c:\program files\python36-64\lib\site-packages\numba\compiler_machinery.py in run(self, state)
326                     (self.pipeline_name, pass_desc)
327                 patched_exception = self._patch_error(msg, e)
--> 328                 raise patched_exception
329
330     def dependency_analysis(self):

c:\program files\python36-64\lib\site-packages\numba\compiler_machinery.py in run(self, state)
317                 pass_inst = _pass_registry.get(pss).pass_inst
318                 if isinstance(pass_inst, CompilerPass):
--> 319                     self._runPass(idx, pass_inst, state)
320                 else:
321                     raise BaseException("Legacy pass in use")

c:\program files\python36-64\lib\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

c:\program files\python36-64\lib\site-packages\numba\compiler_machinery.py in _runPass(self, index, pss, internal_state)
279             mutated |= check(pss.run_initialization, internal_state)
280         with SimpleTimer() as pass_time:
--> 281             mutated |= check(pss.run_pass, internal_state)
282         with SimpleTimer() as finalize_time:
283             mutated |= check(pss.run_finalizer, internal_state)

c:\program files\python36-64\lib\site-packages\numba\compiler_machinery.py in check(func, compiler_state)
266
267         def check(func, compiler_state):
--> 268             mangled = func(compiler_state)
269             if mangled not in (True, False):
270                 msg = ("CompilerPass implementations should return True/False. "

c:\program files\python36-64\lib\site-packages\numba\typed_passes.py in run_pass(self, state)
378             state.library.enable_object_caching()
379
--> 380         NativeLowering().run_pass(state) # TODO: Pull this out into the pipeline
381         lowered = state['cr']
382         signature = typing.signature(state.return_type, *state.args)

c:\program files\python36-64\lib\site-packages\numba\typed_passes.py in run_pass(self, state)
323                 lower = lowering.Lower(targetctx, library, fndesc, interp,
324                                        metadata=metadata)
--> 325                 lower.lower()
326                 if not flags.no_cpython_wrapper:
327                     lower.create_cpython_wrapper(flags.release_gil)

c:\program files\python36-64\lib\site-packages\numba\lowering.py in lower(self)
177         if self.generator_info is None:
178             self.genlower = None
--> 179             self.lower_normal_function(self.fndesc)
180         else:
181             self.genlower = self.GeneratorLower(self)

c:\program files\python36-64\lib\site-packages\numba\lowering.py in lower_normal_function(self, fndesc)
218         # Init argument values
219         self.extract_function_arguments()
--> 220         entry_block_tail = self.lower_function_body()
221
222         # Close tail of entry block

c:\program files\python36-64\lib\site-packages\numba\lowering.py in lower_function_body(self)
243             bb = self.blkmap[offset]
244             self.builder.position_at_end(bb)
--> 245             self.lower_block(block)
246
247         self.post_lower()

c:\program files\python36-64\lib\site-packages\numba\lowering.py in lower_block(self, block)
258             with new_error_context('lowering "{inst}" at {loc}', inst=inst,
259                                    loc=self.loc, errcls_=defaulterrcls):
--> 260                 self.lower_inst(inst)
261
262     def create_cpython_wrapper(self, release_gil=False):

c:\program files\python36-64\lib\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

c:\program files\python36-64\lib\site-packages\numba\errors.py in new_error_context(fmt_, *args, **kwargs)
723         from numba import config
724         tb = sys.exc_info()[2] if config.FULL_TRACEBACKS else None
--> 725         six.reraise(type(newerr), newerr, tb)
726
727

c:\program files\python36-64\lib\site-packages\numba\six.py in reraise(tp, value, tb)
667         if value.__traceback__ is not tb:
668             raise value.with_traceback(tb)
--> 669         raise value
670
671 else:

LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)


File "<string>", line 3:
<source missing, REPL/exec in use?>

[1] During: lowering "$0.5 = call $0.1(start, end, fields, func=$0.1, args=[Var(start, <string> (3)), Var(end, <string> (3)), Var(fields, <string> (3))], kws=(), vararg=None)" at <string> (3)

-------------------------------------------------------------------------------
This should not have happened, a problem has occurred in Numba's internals.
You are currently using Numba version 0.46.0.

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!

# Fixed code
def generic(self, args, kws):
    # Redirect resolution to __init__
    instance_type = self.key.instance_type
    ctor = instance_type.jitmethods["__init__"]
    boundargs = (instance_type.get_reference_type(),) + args
    disp_type = types.Dispatcher(ctor)
    sig = disp_type.get_call_type(self.context, boundargs, kws)

    if not isinstance(sig.return_type, types.NoneType):
        raise TypeError(f"__init__() should return None, not '{sig.return_type}'")

    # Actual constructor returns an instance value (not None)
    out = templates.signature(instance_type, *sig.args[1:])
    return out