diff options
Diffstat (limited to 'tests/basics/assign_expr.py')
-rw-r--r-- | tests/basics/assign_expr.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/basics/assign_expr.py b/tests/basics/assign_expr.py index f243905dc2..2cf604193b 100644 --- a/tests/basics/assign_expr.py +++ b/tests/basics/assign_expr.py @@ -12,6 +12,17 @@ x = 1 print(x, x := 5, x) print(x) +# Test "while" with assignment expression as conditional, assigning to a new local. +# The while conditional is compiled after the while body, so this tests how the +# compiler handles the case of an unbound local being compiled before it is assigned. +def f(): + l = [0, 1] + while local := len(l): + print(local, l.pop()) + + +f() + def foo(): print("any", any((hit := i) % 5 == 3 and (hit % 2) == 0 for i in range(10))) |