Skip to content

Commit d7f7fd2

Browse files
committed
Fix slice location
1 parent d1811c7 commit d7f7fd2

File tree

3 files changed

+123
-1
lines changed

3 files changed

+123
-1
lines changed

compiler/parser/python.lalrpop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ SubscriptList: ast::Expr = {
10181018

10191019
Subscript: ast::Expr = {
10201020
Test<"all">,
1021-
<e1:Test<"all">?> <location:@L> ":" <e2:Test<"all">?> <e3:SliceOp?> <end_location:@R> => {
1021+
<location:@L> <e1:Test<"all">?> ":" <e2:Test<"all">?> <e3:SliceOp?> <end_location:@R> => {
10221022
let lower = e1.map(Box::new);
10231023
let upper = e2.map(Box::new);
10241024
let step = e3.flatten().map(Box::new);

compiler/parser/src/parser.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,11 @@ class Foo(A, B):
233233
let parse_ast = parse_expression(&source, "<test>").unwrap();
234234
insta::assert_debug_snapshot!(parse_ast);
235235
}
236+
237+
#[test]
238+
fn test_slice() {
239+
let source = String::from("x[1:2:3]");
240+
let parse_ast = parse_expression(&source, "<test>").unwrap();
241+
insta::assert_debug_snapshot!(parse_ast);
242+
}
236243
}

compiler/parser/src/snapshots/rustpython_parser__parser__tests__slice.snap

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)