blueloveTH 9 mesi fa
parent
commit
e473fe7f05
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      src/compiler/compiler.c

+ 2 - 2
src/compiler/compiler.c

@@ -2061,14 +2061,14 @@ static Error* compile_match_case(Compiler* self, c11_vector* patches) {
                 int break_patch = Ctx__emit_(ctx(), OP_JUMP_FORWARD, BC_NOARG, prev()->line);
                 int break_patch = Ctx__emit_(ctx(), OP_JUMP_FORWARD, BC_NOARG, prev()->line);
                 c11_vector__push(int, patches, break_patch);
                 c11_vector__push(int, patches, break_patch);
             }
             }
+        } else {
+            return SyntaxError(self, "expected 'case', got '%s'", TokenSymbols[curr()->type]);
         }
         }
 
 
         match_newlines();
         match_newlines();
     }
     }
     consume(TK_DEDENT);
     consume(TK_DEDENT);
 
 
-    if(patches->length == 0) return SyntaxError(self, "invalid syntax");
-
     for(int i = 0; i < patches->length; i++) {
     for(int i = 0; i < patches->length; i++) {
         int patch = c11__getitem(int, patches, i);
         int patch = c11__getitem(int, patches, i);
         Ctx__patch_jump(ctx(), patch);
         Ctx__patch_jump(ctx(), patch);