Skip to content

Commit 999ec9a

Browse files
authored
bpo-40334: Add type to the assignment rule in the grammar file (GH-19963)
1 parent b7aa23d commit 999ec9a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Grammar/python.gram

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ compound_stmt[stmt_ty]:
8282
| &'while' while_stmt
8383

8484
# NOTE: annotated_rhs may start with 'yield'; yield_expr must start with 'yield'
85-
assignment:
85+
assignment[stmt_ty]:
8686
| a=NAME ':' b=expression c=['=' d=annotated_rhs { d }] {
8787
CHECK_VERSION(
8888
6,

Parser/pegen/parse.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static asdl_seq* statement_newline_rule(Parser *p);
378378
static asdl_seq* simple_stmt_rule(Parser *p);
379379
static stmt_ty small_stmt_rule(Parser *p);
380380
static stmt_ty compound_stmt_rule(Parser *p);
381-
static void *assignment_rule(Parser *p);
381+
static stmt_ty assignment_rule(Parser *p);
382382
static AugOperator* augassign_rule(Parser *p);
383383
static stmt_ty global_stmt_rule(Parser *p);
384384
static stmt_ty nonlocal_stmt_rule(Parser *p);
@@ -1256,7 +1256,7 @@ small_stmt_rule(Parser *p)
12561256
int start_col_offset = p->tokens[mark]->col_offset;
12571257
UNUSED(start_col_offset); // Only used by EXTRA macro
12581258
{ // assignment
1259-
void *assignment_var;
1259+
stmt_ty assignment_var;
12601260
if (
12611261
(assignment_var = assignment_rule(p))
12621262
)
@@ -1586,13 +1586,13 @@ compound_stmt_rule(Parser *p)
15861586
// | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
15871587
// | target augassign (yield_expr | star_expressions)
15881588
// | invalid_assignment
1589-
static void *
1589+
static stmt_ty
15901590
assignment_rule(Parser *p)
15911591
{
15921592
if (p->error_indicator) {
15931593
return NULL;
15941594
}
1595-
void * res = NULL;
1595+
stmt_ty res = NULL;
15961596
int mark = p->mark;
15971597
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
15981598
p->error_indicator = 1;

0 commit comments

Comments
 (0)