fix impl of pep695

This commit is contained in:
blueloveTH 2025-01-06 14:09:39 +08:00
parent 9914c4838c
commit 697312cae5
2 changed files with 8 additions and 2 deletions

View File

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

View File

@ -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