Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The value of the variable does not change in the while True: loops #4915

Closed
dlimpid opened this issue Dec 2, 2019 · 4 comments
Closed

The value of the variable does not change in the while True: loops #4915

dlimpid opened this issue Dec 2, 2019 · 4 comments
Labels
no action required No action was needed to resolve.

Comments

@dlimpid
Copy link

dlimpid commented Dec 2, 2019

I've read #2769, #3214, and #4535, but I'm not sure whether these are the same or not.

When I wrote the infinite loop with while True:, the value of the variable does not change (runs with no errors but the result is wrong).

@numba.njit
def foo(value):
    a = 0
    while True:
        print(a, value)
        value = value * 16807 % 2147483647
        if a > 3:
            return value
        a += 1

foo(65)

Without numba:

0 65
1 1092455
2 1181022009
3 245556042
4 1744312007

With numba:

0 65
1 65
2 65
3 65
4 65
  • @numba.njit(numba.int64(numba.int64)) does not help.
  • break in the while loop and return at the last of the function does not help.
  • while True == True: solves the problem.

Thank you.

My env: Python 3.8.0, numba 0.46.0

@stuartarchibald
Copy link
Contributor

Thanks for the report, this seems to only reproduce on Python 3.8, so would guess at it being a CFG/analysis issue from the recent rewrite of this part of the code.

CC @sklam.

@sklam
Copy link
Member

sklam commented Dec 2, 2019

checking this now

@sklam
Copy link
Member

sklam commented Dec 2, 2019

I can't replicate this on master ceab106

@sklam
Copy link
Member

sklam commented Dec 2, 2019

Note, the bug happens on tag 0.46.0 because at that point numba doesn't support py3.8.

@sklam sklam added no action required No action was needed to resolve. and removed bug labels Dec 2, 2019
@sklam sklam closed this as completed Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no action required No action was needed to resolve.
Projects
None yet
Development

No branches or pull requests

3 participants