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

UnboundLocalError not implemented #1

Open
tusharsadhwani opened this issue Jul 28, 2023 · 1 comment
Open

UnboundLocalError not implemented #1

tusharsadhwani opened this issue Jul 28, 2023 · 1 comment
Labels

Comments

@tusharsadhwani
Copy link
Owner

tusharsadhwani commented Jul 28, 2023

The interpreter currently doesn't check if a variable is being read before being assigned to in a scope.

It leads to bugs like this:

x = 10

def f():
    x = x + 1  # accidentally reading the variable from global, but writing in local
    print(x)

f()
print(x)
$ interpreted asd.py
11
10

This should throw UnboundLocalError instead.

@vinsmoke0003
Copy link

yess

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

Successfully merging a pull request may close this issue.

2 participants