[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

@ -126,8 +126,6 @@ pub enum ParseErrorType {
/// A default value was found for a `*` or `**` parameter.
VarParameterWithDefault,
/// A duplicate parameter was found in a function definition or lambda expression.
DuplicateParameter(String),
/// A keyword argument was repeated.
DuplicateKeywordArgumentError(String),
@ -285,9 +283,6 @@ impl std::fmt::Display for ParseErrorType {
f.write_str("Invalid augmented assignment target")
}
ParseErrorType::InvalidDeleteTarget => f.write_str("Invalid delete target"),
ParseErrorType::DuplicateParameter(arg_name) => {
write!(f, "Duplicate parameter {arg_name:?}")
}
ParseErrorType::DuplicateKeywordArgumentError(arg_name) => {
write!(f, "Duplicate keyword argument {arg_name:?}")
}