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

breaking from inner loop to the outer corrupts loop variable #38

Open
igolotin opened this issue Oct 27, 2021 · 0 comments
Open

breaking from inner loop to the outer corrupts loop variable #38

igolotin opened this issue Oct 27, 2021 · 0 comments

Comments

@igolotin
Copy link

igolotin commented Oct 27, 2021

Code to reproduce:

from goto import with_goto

content = ["ab", "cd"]
prefix = ['a', 'b']

@with_goto
def test():
    for a in content:
        print(f"1: {a}")
        for p in prefix:
            if a.startswith(p):
                print(f"2: {a}")
                goto .end
        label .end
        print(f"3: {a}")

Expected output for the test() call:

1: ab
2: ab
3: ab
1: ab
3: ab

Actual output:

1: ab
2: ab
3: ab
1: b
2: b
3: b

Version:

python: Python 3.9.7
OS: windows x64

Some thoughts:
I believe that at some point the stack become corrupted and inner loop iterations are written to the outer loop variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant