Skip to content

nonlocal raise SyntaxError when it is declared multiple times. #2183

@minoring

Description

@minoring

CPython 3.7.4

def test_nonlocal():
    x = 0
    y = 0
    def f():
        nonlocal x
        nonlocal x, y

def test_nonlocal2():
    x = 0
    def f():
        nonlocal x
        nonlocal x

are OK.

RustPython gives SyntaxError: name 'x' is used prior to nonlocal declaration at line 0 column 0 for both of the examples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatA discrepancy between RustPython and CPython

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions