Skip to content

Crash of interpreter due to assign before global declaration #111132

@Eclips4

Description

@Eclips4

Crash report

What happened?

def bar():
    x = 11
    global x
    return x

bar()

Traceback:

File "/Users/admin/Projects/cpython/example.py", line 3
    global x
    ^^^^^^^^
SyntaxError: name 'x' is assigned to before global declaration
Assertion failed: ((gc->_gc_next & NEXT_MASK_UNREACHABLE) == next_value), function validate_list, file gcmodule.c, line 403.
zsh: abort      ./python.exe example.py

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Output from running 'python -VV' on the command line:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions