bpo-40334: Reproduce error message for type comments on bare '*' in the new parser (GH-20151)
diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c
index e9c2032..fe95d27 100644
--- a/Parser/pegen/parse.c
+++ b/Parser/pegen/parse.c
@@ -12041,7 +12041,7 @@
return _res;
}
-// invalid_star_etc: '*' (')' | ',' (')' | '**'))
+// invalid_star_etc: '*' (')' | ',' (')' | '**')) | '*' ',' TYPE_COMMENT
static void *
invalid_star_etc_rule(Parser *p)
{
@@ -12071,6 +12071,27 @@
}
p->mark = _mark;
}
+ { // '*' ',' TYPE_COMMENT
+ Token * _literal;
+ Token * _literal_1;
+ Token * type_comment_var;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
+ )
+ {
+ _res = RAISE_SYNTAX_ERROR ( "bare * has associated type comment" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ }
_res = NULL;
done:
return _res;