Skip to content

UnboundLocalError not implemented #1

Open
@tusharsadhwani

Description

@tusharsadhwani

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions