diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index f97e5f70..29c93e60 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -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)); diff --git a/tests/95_bugs.py b/tests/95_bugs.py index 1916c34d..ea341717 100644 --- a/tests/95_bugs.py +++ b/tests/95_bugs.py @@ -148,4 +148,13 @@ assert A.x == [1, 2, 3] 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 \ No newline at end of file + 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 \ No newline at end of file