Skip to content

numba jit: "Type of variable <varname>.2 cannot be determined" for a fully specified variable. #128548

@dakra137

Description

@dakra137

Bug report

Bug description:

I have several functions that work fine with jit and njit. All variables are explicitly typed, such as

def afun(parm1:int, parm2:int)->list[int]:
   varname:int=3
   listname:list[int]=[0]

In one function, the jit complains about a variable as having an undeterminable type, even though it has been explicitly typed:
Type of variable 'artp.2' cannot be determined, operation: call $1078load_global.2($binop_add1104.10, func=$1078load_global.2, args=[Var($binop_add1104.10, primes2025a.py:240)], kws=(), vararg=None, varkwarg=None, target=None), location: /home/dakra/./primes2025a.py (240)

where the code looks like:

from numba import njit
from numba import jit

@jit 
def sieve12(upToNumm: int=100000000, pnprimorial:int=3) -> list[int]:
#  early in the function similar to:
    C0:int=0
    modprimorialdo:list[int]=[1,5]
    lmodprimorialdo:int=len(modprimorialdo)
    ddocol:int=C0
    fdorowcol:list[int]=[C0,C0]
    artp:int=C0

# and later:  
   # there are assignment statements for useful values for these variables, and then:
    artp:int=int(ddocol+fdorowcol[C0]*lmodprimorialdo))

The full error report is :

Traceback (most recent call last):
  File "/home/dakra/./primes2025a.py", line 810, in <module>
    print("sieve12",n,pr,len(primesl:=sieve12(n,pr)), primesl[:10], primesl[-10:])
                                      ^^^^^^^^^^^^^
  File "/home/dakra/.local/lib/python3.12/site-packages/numba/core/dispatcher.py", line 423, in _compile_for_args
    error_rewrite(e, 'typing')
  File "/home/dakra/.local/lib/python3.12/site-packages/numba/core/dispatcher.py", line 364, in error_rewrite
    raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Type of variable 'artp.2' cannot be determined, operation: call $1078load_global.2($binop_add1104.10, func=$1078load_global.2, args=[Var($binop_add1104.10, primes2025a.py:240)], kws=(), vararg=None, varkwarg=None, target=None), location: /home/dakra/./primes2025a.py (240)

File "primes2025a.py", line 240:
def sieve12(upToNumm: int=100000000, pnprimorial:int=3)->list[int]: 
    <source elided>

           artp:int=int(ddocol+fdorowcol[C0]*lmodprimorialdo)
           ^

In another case, the jit processing complained about one of the parameters.
What does it take to get the jit to recognize the explicit type specifications?

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions