mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-09 22:25:23 +00:00
Fix end location for elif blocks
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>
This commit is contained in:
parent
b26365b215
commit
6dba8430be
2 changed files with 3 additions and 3 deletions
|
@ -372,7 +372,7 @@ IfStatement: ast::Stmt = {
|
||||||
let x = ast::Stmt {
|
let x = ast::Stmt {
|
||||||
custom: (),
|
custom: (),
|
||||||
location: i.0,
|
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 },
|
node: ast::StmtKind::If { test: Box::new(i.2), body: i.4, orelse: last },
|
||||||
};
|
};
|
||||||
last = vec![x];
|
last = vec![x];
|
||||||
|
|
|
@ -79,8 +79,8 @@ expression: parse_ast
|
||||||
},
|
},
|
||||||
end_location: Some(
|
end_location: Some(
|
||||||
Location {
|
Location {
|
||||||
row: 2,
|
row: 3,
|
||||||
column: 10,
|
column: 8,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
custom: (),
|
custom: (),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue