discard '_'

This commit is contained in:
blueloveTH 2025-12-25 18:12:04 +08:00
parent d6052da6ab
commit 1e2135e153
2 changed files with 7 additions and 6 deletions

View File

@ -1254,6 +1254,10 @@ static int Ctx__add_const(Ctx* self, py_Ref v) {
}
static void Ctx__emit_store_name(Ctx* self, NameScope scope, py_Name name, int line) {
if(name == py_name("_")) {
Ctx__emit_(self, OP_POP_TOP, BC_NOARG, line);
return;
}
switch(scope) {
case NAME_LOCAL: Ctx__emit_(self, OP_STORE_FAST, Ctx__add_varname(self, name), line); break;
case NAME_GLOBAL: {
@ -2593,9 +2597,7 @@ __EAT_DOTS_END:
}
Ctx__emit_store_name(ctx(), name_scope(self), py_namev(name), prev()->line);
} while(match(TK_COMMA));
if(has_bracket) {
consume(TK_RPAREN);
}
if(has_bracket) { consume(TK_RPAREN); }
Ctx__emit_(ctx(), OP_POP_TOP, BC_NOARG, BC_KEEPLINE);
consume_end_stmt();
return NULL;

View File

@ -125,9 +125,8 @@ else:
assert x == 2
# match case
case, _ = 1, 2
assert case == 1 and _ == 2
case, _1 = 1, 2
assert case == 1 and _1 == 2
match (404 * 1):
case 200: