Repository navigation
Added inline_closurecall as an import during registry loading - #9596
Conversation
|
Can you add a test? |
|
This is a bit hard to add as a test. The problem isn't as much as an import as it is of registration. The failure is actually because the code logic is unable to determine the type of class i.e. to add a test for this we'd need a mechanism to basically run it in an isolated environment. (Not sure how that'd look like) |
|
It could look like this ( from numba.tests.support import TestCase
import unittest
import numpy as np
import numba
@numba.njit
def issue_9577():
range_start = 0
for _ in range(1):
np.array([
1 for _ in range(range_start, 7)
])
range_start = 0
class TestIssue9577(TestCase):
@TestCase.run_test_in_subprocess
def test_issue_9577(self):
issue_9577()
if __name__ == '__main__':
unittest.main() |
|
Ah okay, the |
gmarkall
left a comment
There was a problem hiding this comment.
This works as far as fixing the issue is concerned, so I'm going to approve it on that basis.
However, I do think there's something super-suspicious as to why it works. inline_closurecall is imported before _inline_arraycall creates a reference to a global called length_of_iterator (this should seem trivial), so my expectation is that this issue shouldn't have occurred - decorating with the @intrinsic decorator should already have made length_of_iterator available. My initial hypothesis is that somehow the typing context is not refreshed when required, but I don't want to go too much deeper into the issue as part of the review here.
|
(I've marked for a second review in case someone else thinks we ought to dig deeper into the underling issue now, or later) |
|
For additional context; a breakpoint at the point of failure: Line 1581 in 556545c Throws the error: Which gets rewitten as the error: due to the following logic: Lines 1594 to 1601 in 556545c |
|
Thanks for the context - additionally, the typing for that Lines 352 to 361 in 556545c However, I think the typing context was never refreshed after this and prior to the |
|
Indeed it works after adding a context refresh() in diff --git a/numba/core/cpu.py b/numba/core/cpu.py
index ec55a2d5a..130e47c5b 100644
--- a/numba/core/cpu.py
+++ b/numba/core/cpu.py
@@ -71,7 +71,7 @@ class CPUContext(BaseContext):
listobj, numbers, rangeobj, # noqa F401
setobj, slicing, tupleobj, # noqa F401
unicode,) # noqa F401
- from numba.core import optional, inline_closurecall # noqa F401
+ from numba.core import optional # noqa F401
from numba.misc import gdb_hook, literal # noqa F401
from numba.np import linalg, arraymath, arrayobj # noqa F401
from numba.np.random import generator_core, generator_methods # noqa F401
diff --git a/numba/core/typeinfer.py b/numba/core/typeinfer.py
index 0280dd9f5..934bb821e 100644
--- a/numba/core/typeinfer.py
+++ b/numba/core/typeinfer.py
@@ -1499,6 +1499,13 @@ https://numba.readthedocs.io/en/stable/user/troubleshoot.html#my-code-has-an-unt
return self.context.resolve_value_type(val)
except ValueError as e:
msg = str(e)
+
+ self.context.refresh()
+ try:
+ return self.context.resolve_value_type(val)
+ except ValueError as e:
+ msg = str(e)
+
raise TypingError(msg, loc=inst.loc)
def typeof_arg(self, inst, target, arg):
|
|
Thanks for confirming @sklam. I think we should:
|
|
Unfortunately this PR had targeted the branch |
Fixes: #9577
This PR intends to fix the import issue caused by a
0.60.0rc1regression introduced in #9437.