Procházet zdrojové kódy

fix impl of pep695

blueloveTH před 1 rokem
rodič
revize
697312cae5
2 změnil soubory, kde provedl 8 přidání a 2 odebrání
  1. 4 2
      src/compiler/compiler.c
  2. 4 0
      tests/96_pep695_py312.py

+ 4 - 2
src/compiler/compiler.c

@@ -2269,8 +2269,10 @@ static Error* consume_pep695_py312(Compiler* self) {
     // https://peps.python.org/pep-0695/
     Error* err;
     if(match(TK_LBRACKET)) {
-        consume(TK_ID);
-        if(match(TK_COLON)) { check(consume_type_hints(self)); }
+        do {
+            consume(TK_ID);
+            if(match(TK_COLON)) check(consume_type_hints(self));
+        } while(match(TK_COMMA));
         consume(TK_RBRACKET);
     }
     return NULL;

+ 4 - 0
tests/96_pep695_py312.py

@@ -15,3 +15,7 @@ assert res == 3
 
 test = Test(1)
 assert test.get_value() == 1
+
+# test multiple
+class Test2[T: int, U]: pass
+class Test3[T: int | str, U: float, R: list]: pass