You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> global a; a=0; print([(a:=a+1) for b in range(10)])
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
MicroPython (UNIX standard):
>>> global a; a=0; print([(a:=a+1) for b in range(10)])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <listcomp>
NameError: local variable referenced before assignment
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.
The text was updated successfully, but these errors were encountered: