ruff/crates/ruff_python_parser/tests/snapshots/invalid_syntax@star_slices.py.snap
Brent Westbrook 4f2851982d
[syntax-errors] Star expression in index before Python 3.11 (#16544)
Summary
--

This PR detects tuple unpacking expressions in index/subscript
expressions before Python 3.11.

Test Plan
--

New inline tests
2025-03-14 14:51:34 +00:00

81 lines
3 KiB
Text

---
source: crates/ruff_python_parser/tests/fixtures.rs
input_file: crates/ruff_python_parser/resources/inline/err/star_slices.py
---
## AST
```
Module(
ModModule {
range: 0..19,
body: [
Expr(
StmtExpr {
range: 0..18,
value: Subscript(
ExprSubscript {
range: 0..18,
value: Name(
ExprName {
range: 0..5,
id: Name("array"),
ctx: Load,
},
),
slice: Slice(
ExprSlice {
range: 6..17,
lower: Some(
Starred(
ExprStarred {
range: 6..12,
value: Name(
ExprName {
range: 7..12,
id: Name("start"),
ctx: Load,
},
),
ctx: Load,
},
),
),
upper: Some(
Starred(
ExprStarred {
range: 13..17,
value: Name(
ExprName {
range: 14..17,
id: Name("end"),
ctx: Load,
},
),
ctx: Load,
},
),
),
step: None,
},
),
ctx: Load,
},
),
},
),
],
},
)
```
## Errors
|
1 | array[*start:*end]
| ^^^^^^ Syntax Error: Starred expression cannot be used here
|
|
1 | array[*start:*end]
| ^^^^ Syntax Error: Starred expression cannot be used here
|