works if each walrus is wrapped in parens

This commit is contained in:
aps 2023-02-15 12:49:27 -05:00
parent 61be706c7d
commit 3bc3114a50
2 changed files with 23 additions and 12 deletions

View File

@ -503,7 +503,7 @@ private:
}
void exprGrouping() {
// co()->_rvalue = true;
//co()->_rvalue = true;
match_newlines(mode()==REPL_MODE);
do {
if (peek() == TK(")")) break;
@ -521,16 +521,16 @@ private:
// in the expression
consume(TK(":="));
emit(OP_LOAD_NAME_REF, index);
EXPR();
EXPR_TUPLE();
// emit(OP_LOAD_NAME, index);
emit(OP_STORE_REF);
emit(OP_LOAD_NAME_REF, index);;
}
else EXPR();
else EXPR_TUPLE();
} while (match(TK(",")));
match_newlines(mode()==REPL_MODE);
consume(TK(")"));
// co()->_rvalue = false;
//co()->_rvalue = false;
}
void exprList() {

View File

@ -119,13 +119,24 @@ assert round(-23.2) == -23
assert round(-23.8) == -24
assert (x := 1) == 1
assert (x := 1, y := 2 ) == (1, 2)
z = (a := 1, b := 2)
print(z)
z = (x := 2)
assert z == 2
assert ((a:=1),(b:=2,3)) == (1, (2,3))
assert a == 1
assert b == 2
assert b == (2,3)
assert (x := (a := 1, b := 2)) == (1, 2)
assert x == 1
assert (x := 0) + 1 == 1
assert (x := 1, y := 2, 3) == (1,2,3)
# Note in Python3
# >>> (x := 1,2,y:=3)
# (1, 2, 3)
# with x == 1, y == 3
#assert (x := 1, y := 2 ) == (1, 2)
# z = (a := 1, b := 2)
# print(z)
# assert a == 1
# assert b == 2
# assert (x := (a := 1, b := 2)) == (1, 2)
# assert x == 1
# assert (x := 0) + 1 == 1
# assert (x := 1, y := 2, 3) == (1,2,3)