Files
openide/python/testData/highlighting/invalidAssignmentExpressions.py
Semyon Proshev 9335c066f5 Make parser stricter for assignment expressions (PY-33886, PY-36478)
Now it more follows original python grammar.

GitOrigin-RevId: f2b45554d16ff87d946950591f0e92fedcfdfaf0
2020-11-24 17:34:59 +00:00

8 lines
546 B
Python

<error descr="Unparenthesized assignment expressions are prohibited at the top level of an expression statement">y := f(x)</error> # INVALID
(y := f(x)) # Valid, though not recommended
y0 = <error descr="Unparenthesized assignment expressions are prohibited at the top level of the right hand side of an assignment statement">y1 := f(x)</error> # INVALID
y0 = (y1 := f(x)) # Valid, though discouraged
class A:
[<error descr="Assignment expressions within a comprehension cannot be used in a class body">y := i</error> for i in range(2)]