[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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 70 additions and 44 deletions

View file

@ -615,7 +615,8 @@ impl SemanticSyntaxContext for Checker<'_> {
| SemanticSyntaxErrorKind::DuplicateMatchKey(_)
| SemanticSyntaxErrorKind::DuplicateMatchClassAttribute(_)
| SemanticSyntaxErrorKind::InvalidStarExpression
| SemanticSyntaxErrorKind::AsyncComprehensionOutsideAsyncFunction(_) => {
| SemanticSyntaxErrorKind::AsyncComprehensionOutsideAsyncFunction(_)
| SemanticSyntaxErrorKind::DuplicateParameter(_) => {
if self.settings.preview.is_enabled() {
self.semantic_errors.borrow_mut().push(error);
}