File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1018,7 +1018,7 @@ SubscriptList: ast::Expr = {
10181018
10191019Subscript: 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);
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 1+ -- -
2+ source : compiler / parser / src / parser .rs
3+ expression : parse_ast
4+ -- -
5+ Located {
6+ location : Location {
7+ row : 1 ,
8+ column : 0 ,
9+ },
10+ end_location : Some (
11+ Location {
12+ row: 1 ,
13+ column: 8 ,
14+ },
15+ ),
16+ custom : (),
17+ node : Subscript {
18+ value : Located {
19+ location : Location {
20+ row : 1 ,
21+ column : 0 ,
22+ },
23+ end_location : Some (
24+ Location {
25+ row: 1 ,
26+ column: 1 ,
27+ },
28+ ),
29+ custom : (),
30+ node : Name {
31+ id : " x" ,
32+ ctx : Load ,
33+ },
34+ },
35+ slice : Located {
36+ location : Location {
37+ row : 1 ,
38+ column : 2 ,
39+ },
40+ end_location : Some (
41+ Location {
42+ row: 1 ,
43+ column: 7 ,
44+ },
45+ ),
46+ custom : (),
47+ node : Slice {
48+ lower : Some (
49+ Located {
50+ location: Location {
51+ row: 1 ,
52+ column: 2 ,
53+ },
54+ end_location: Some (
55+ Location {
56+ row: 1 ,
57+ column: 3 ,
58+ },
59+ ),
60+ custom: (),
61+ node: Constant {
62+ value: Int (
63+ 1 ,
64+ ),
65+ kind: None ,
66+ },
67+ },
68+ ),
69+ upper : Some (
70+ Located {
71+ location: Location {
72+ row: 1 ,
73+ column: 4 ,
74+ },
75+ end_location: Some (
76+ Location {
77+ row: 1 ,
78+ column: 5 ,
79+ },
80+ ),
81+ custom: (),
82+ node: Constant {
83+ value: Int (
84+ 2 ,
85+ ),
86+ kind: None ,
87+ },
88+ },
89+ ),
90+ step : Some (
91+ Located {
92+ location: Location {
93+ row: 1 ,
94+ column: 6 ,
95+ },
96+ end_location: Some (
97+ Location {
98+ row: 1 ,
99+ column: 7 ,
100+ },
101+ ),
102+ custom: (),
103+ node: Constant {
104+ value: Int (
105+ 3 ,
106+ ),
107+ kind: None ,
108+ },
109+ },
110+ ),
111+ },
112+ },
113+ ctx : Load ,
114+ },
115+ }
You can’t perform that action at this time.
0 commit comments