Merge pull request #176 from Terseus/bugfix/175-nonlocal-parameter

Prevent incorrect syntax error with nonlocal of a parameter
This commit is contained in:
Dave Halter
2021-03-09 00:50:03 +01:00
committed by GitHub
3 changed files with 37 additions and 0 deletions

View File

@@ -337,6 +337,13 @@ FAILING_EXAMPLES = [
def z():
nonlocal a
'''),
# Name is assigned before nonlocal declaration
dedent('''
def x(a):
def y():
a = 10
nonlocal a
'''),
]
if sys.version_info[:2] >= (3, 7):

View File

@@ -135,6 +135,29 @@ def x():
nonlocal a
def x(a):
def y():
nonlocal a
def x(a, b):
def y():
nonlocal b
nonlocal a
def x(a):
def y():
def z():
nonlocal a
def x():
def y(a):
def z():
nonlocal a
a = *args, *args
error[(*args, *args)] = 3
*args, *args