Skip to content

Commit

Permalink
Fix end location for elif blocks
Browse files Browse the repository at this point in the history
Since we parse an `elif:` block as an `If` node, its location should
include its `orelse` node like it would for an `if:` block.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Loading branch information
andersk committed Jan 18, 2023
1 parent b26365b commit 6dba843
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion parser/python.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ IfStatement: ast::Stmt = {
let x = ast::Stmt {
custom: (),
location: i.0,
end_location: i.4.last().unwrap().end_location,
end_location,
node: ast::StmtKind::If { test: Box::new(i.2), body: i.4, orelse: last },
};
last = vec![x];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ expression: parse_ast
},
end_location: Some(
Location {
row: 2,
column: 10,
row: 3,
column: 8,
},
),
custom: (),
Expand Down

0 comments on commit 6dba843

Please sign in to comment.