Skip to content

Assignment expression raises error if updating global variable #14376

@rkompass

Description

@rkompass

Checks

  • I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.

  • I've searched for existing issues matching this bug, and didn't find any.

Port, board and/or hardware

w600, RP2, others

MicroPython version

MicroPython v1.23.0-preview.362.g3995158d9.dirty on 2024-04-19

Reproduction

a=0; print([(a:=a+1) for b in range(10)])

Expected behaviour

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Observed behaviour

SyntaxError: identifier redefined as global

Additional Information

I saw the discussion on #4908
but there it is about a variable created in the comprehension context being available as global outside.

Here is a variable already present as global.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy