[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:
Brent Westbrook
2025-04-23 15:45:51 -04:00
committed by GitHub
parent 9db63fc58c
commit d5410ef9fe
6 changed files with 70 additions and 44 deletions

View File

@@ -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 |

View File

@@ -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): ...