Skip to content

Temporal Dead Zone in Python #47

@martin-henz

Description

@martin-henz
y = 1
def f(x):
    print(y)
    if True:
        print("true")
        y = 3
    else:
        print("false")
    print(y)
    
f(4)

This program should give

UnboundLocalError: local variable 'y' referenced before assignment

but currently gives no error:

undefined
"true"
3
undefined

Program: https://share.sourceacademy.org/25fj7

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions