[syntax-errors] Duplicate type parameter names (#16858)

Summary
--

Detects duplicate type parameter names in function definitions, class
definitions, and type alias statements.

I also boxed the `type_params` field on `StmtTypeAlias` to make it
easier to
`match` with functions and classes. (That's the reason for the red-knot
code
owner review requests, sorry!)

Test Plan
--

New `ruff_python_syntax_errors` unit tests.

Fixes #11119.
This commit is contained in:
Brent Westbrook 2025-03-21 15:06:22 -04:00 committed by GitHub
parent 2baaedda6c
commit e4f5fe8cf7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1043 additions and 9 deletions

View file

@ -957,7 +957,7 @@ where
self.with_type_params(
NodeWithScopeRef::TypeAliasTypeParameters(type_alias),
type_alias.type_params.as_ref(),
type_alias.type_params.as_deref(),
|builder| {
builder.push_scope(NodeWithScopeRef::TypeAlias(type_alias));
builder.visit_expr(&type_alias.value);