blueloveTH il y a 2 mois
Parent
commit
1e2135e153
2 fichiers modifiés avec 7 ajouts et 6 suppressions
  1. 5 3
      src/compiler/compiler.c
  2. 2 3
      tests/152_controlflow.py

+ 5 - 3
src/compiler/compiler.c

@@ -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) {
 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) {
     switch(scope) {
         case NAME_LOCAL: Ctx__emit_(self, OP_STORE_FAST, Ctx__add_varname(self, name), line); break;
         case NAME_LOCAL: Ctx__emit_(self, OP_STORE_FAST, Ctx__add_varname(self, name), line); break;
         case NAME_GLOBAL: {
         case NAME_GLOBAL: {
@@ -2593,9 +2597,7 @@ __EAT_DOTS_END:
         }
         }
         Ctx__emit_store_name(ctx(), name_scope(self), py_namev(name), prev()->line);
         Ctx__emit_store_name(ctx(), name_scope(self), py_namev(name), prev()->line);
     } while(match(TK_COMMA));
     } 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);
     Ctx__emit_(ctx(), OP_POP_TOP, BC_NOARG, BC_KEEPLINE);
     consume_end_stmt();
     consume_end_stmt();
     return NULL;
     return NULL;

+ 2 - 3
tests/152_controlflow.py

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