Casting IntEnum to numba.int16

I wasn’t sure what category this should be in, so I used ‘How do I?’. It appears to be a regression in 0.54.1. It doesn’t appear to be related to this item, but that might be of interest. I’m on Windows 10 with Python 3.7.3.

If this is better filed as a git issue, let me know and I’ll cross post it there. My initial comment was in gitter, here’s the min repro.

This code works with plain python and numba 0.53.1 but not 0.54.1

from enum import IntEnum

import numba

class PmtType(IntEnum):
    LEVELA = 1
    LEVELB = 2

def tester():
    return numba.int16(PmtType.LEVELA)


Numba 0.53.1:


Numba 0.54.1:

File “”, line 16, in
File “C:\work\git\mims\venv\lib\site-packages\numba\core\”, line 482, in _compile_for_args
error_rewrite(e, ‘typing’)
File “C:\work\git\mims\venv\lib\site-packages\numba\core\”, line 423, in error_rewrite
raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(int16) found for signature:


There are 2 candidate implementations:

  • Of which 2 did not match due to:
    Overload in function ‘make_callable_template..generic’: File: numba\core\typing\ Line 174.
    With argument(s): ‘(IntEnum(PmtType))’:
    Rejected as the implementation raised a specific error:
    TypingError: Casting IntEnum(PmtType) to int16 directly is unsupported.
    raised from C:\work\git\mims\venv\lib\site-packages\numba\core\typing\

During: resolving callee type: class(int16)
During: typing of call at C:/work/git/ims_core/playground/erik/discourse/ (14)

File “”, line 14:
def tester():
return numba.int16(PmtType.LEVELA)
Process finished with exit code 1

@nelson2005 thanks for reporting this. xref: numba 0.54.1 casting IntEnum regression · Issue #7573 · numba/numba · GitHub, it’s a confirmed bug/regression.