Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-40334: Add type to the assignment rule in the grammar file #19963

Merged
merged 1 commit into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Grammar/python.gram
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ compound_stmt[stmt_ty]:
| &'while' while_stmt

# NOTE: annotated_rhs may start with 'yield'; yield_expr must start with 'yield'
assignment:
assignment[stmt_ty]:
| a=NAME ':' b=expression c=['=' d=annotated_rhs { d }] {
CHECK_VERSION(
6,
Expand Down
8 changes: 4 additions & 4 deletions Parser/pegen/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ static asdl_seq* statement_newline_rule(Parser *p);
static asdl_seq* simple_stmt_rule(Parser *p);
static stmt_ty small_stmt_rule(Parser *p);
static stmt_ty compound_stmt_rule(Parser *p);
static void *assignment_rule(Parser *p);
static stmt_ty assignment_rule(Parser *p);
static AugOperator* augassign_rule(Parser *p);
static stmt_ty global_stmt_rule(Parser *p);
static stmt_ty nonlocal_stmt_rule(Parser *p);
Expand Down Expand Up @@ -1256,7 +1256,7 @@ small_stmt_rule(Parser *p)
int start_col_offset = p->tokens[mark]->col_offset;
UNUSED(start_col_offset); // Only used by EXTRA macro
{ // assignment
void *assignment_var;
stmt_ty assignment_var;
if (
(assignment_var = assignment_rule(p))
)
Expand Down Expand Up @@ -1586,13 +1586,13 @@ compound_stmt_rule(Parser *p)
// | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
// | target augassign (yield_expr | star_expressions)
// | invalid_assignment
static void *
static stmt_ty
assignment_rule(Parser *p)
{
if (p->error_indicator) {
return NULL;
}
void * res = NULL;
stmt_ty res = NULL;
int mark = p->mark;
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
p->error_indicator = 1;
Expand Down