mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-16 01:25:22 +00:00
[syntax-errors] Make duplicate parameter names a semantic error (#17131)
Status -- This is a pretty minor change, but it was breaking a red-knot mdtest until #17463 landed. Now this should close #11934 as the last syntax error being tracked there! Summary -- Moves `Parser::validate_parameters` to `SemanticSyntaxChecker::duplicate_parameter_name`. Test Plan -- Existing tests, with `## Errors` replaced with `## Semantic Syntax Errors`.
This commit is contained in:
parent
9db63fc58c
commit
d5410ef9fe
6 changed files with 70 additions and 44 deletions
|
@ -284,6 +284,16 @@ Module(
|
|||
```
|
||||
## Errors
|
||||
|
||||
|
|
||||
7 | lambda a, *a: 1
|
||||
8 |
|
||||
9 | lambda a, *, **a: 1
|
||||
| ^^^ Syntax Error: Expected one or more keyword parameter after '*' separator
|
||||
|
|
||||
|
||||
|
||||
## Semantic Syntax Errors
|
||||
|
||||
|
|
||||
1 | lambda a, a: 1
|
||||
| ^ Syntax Error: Duplicate parameter "a"
|
||||
|
@ -322,14 +332,6 @@ Module(
|
|||
|
|
||||
|
||||
|
||||
|
|
||||
7 | lambda a, *a: 1
|
||||
8 |
|
||||
9 | lambda a, *, **a: 1
|
||||
| ^^^ Syntax Error: Expected one or more keyword parameter after '*' separator
|
||||
|
|
||||
|
||||
|
||||
|
|
||||
7 | lambda a, *a: 1
|
||||
8 |
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/tests/fixtures.rs
|
||||
input_file: crates/ruff_python_parser/resources/inline/err/params_duplicate_names.py
|
||||
snapshot_kind: text
|
||||
---
|
||||
## AST
|
||||
|
||||
|
@ -132,7 +131,7 @@ Module(
|
|||
},
|
||||
)
|
||||
```
|
||||
## Errors
|
||||
## Semantic Syntax Errors
|
||||
|
||||
|
|
||||
1 | def foo(a, a=10, *a, a, a: str, **a): ...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue