Basic implementation support for namedexpr, fixes #1647

This commit is contained in:
Dave Halter
2020-08-05 10:12:47 +02:00
parent 76c0c373da
commit abf63d73d3
6 changed files with 55 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
x = 3
if NOT_DEFINED:
x = ''
#? 6 int()
#? 6 int() str()
elif x:
pass
else:

View File

@@ -1,3 +1,6 @@
# For assignment expressions / named expressions / walrus operators / whatever
# they are called.
# python >= 3.8
b = (a:=1, a)
@@ -11,3 +14,39 @@ b = ('':=1,)
#? int()
b[0]
def test_assignments():
match = ''
#? str()
match
#? 8 int()
if match := 1:
#? int()
match
#? int()
match
def test_assignments2():
class Foo:
match = ''
#? str()
Foo.match
#? 13 int()
if Foo.match := 1:
#? str()
Foo.match
#? str()
Foo.match
#?
y
#? 16 str()
if y := Foo.match:
#? str()
y
#? str()
y
#? 8 str()
if z := Foo.match:
pass