mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
This commit is contained in:
parent
29cd6fe59b
commit
340309b5d4
@ -479,13 +479,7 @@ bool TupleExpr__emit_store(Expr* self_, Ctx* ctx) {
|
||||
}
|
||||
|
||||
if(starred_i == -1) {
|
||||
Bytecode* prev = c11__at(Bytecode, &ctx->co->codes, ctx->co->codes.length - 1);
|
||||
if(prev->op == OP_BUILD_TUPLE && prev->arg == self->itemCount) {
|
||||
// build tuple and unpack it is meaningless
|
||||
Ctx__revert_last_emit_(ctx);
|
||||
} else {
|
||||
Ctx__emit_(ctx, OP_UNPACK_SEQUENCE, self->itemCount, self->line);
|
||||
}
|
||||
Ctx__emit_(ctx, OP_UNPACK_SEQUENCE, self->itemCount, self->line);
|
||||
} else {
|
||||
// starred assignment target must be in a tuple
|
||||
if(self->itemCount == 1) return false;
|
||||
@ -2177,7 +2171,7 @@ Error* try_compile_assignment(Compiler* self, bool* is_assign) {
|
||||
}
|
||||
case TK_ASSIGN: {
|
||||
consume(TK_ASSIGN);
|
||||
int n = 0;
|
||||
int n = 0; // assignment count
|
||||
|
||||
if(match(TK_YIELD_FROM)) {
|
||||
check(compile_yield_from(self, prev()->line));
|
||||
|
@ -149,3 +149,12 @@ a = [(0, 1), (1, 1), (1, 2)]
|
||||
b = sorted(a, key=lambda x: x[0])
|
||||
if b != [(0, 1), (1, 1), (1, 2)]:
|
||||
assert False, b
|
||||
|
||||
# https://github.com/pocketpy/pocketpy/issues/367
|
||||
a = 10 if False else 5
|
||||
assert a == 5
|
||||
|
||||
a, b, c = (1, 2, 3) if True else (4, 5, 6)
|
||||
assert a == 1
|
||||
assert b == 2
|
||||
assert c == 3
|
Loading…
x
Reference in New Issue
Block a user