[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:
@@ -104,7 +104,7 @@ fields = [{ name = "targets", type = "Expr*" }]
|
||||
doc = "See also [TypeAlias](https://docs.python.org/3/library/ast.html#ast.TypeAlias)"
|
||||
fields = [
|
||||
{ name = "name", type = "Expr" },
|
||||
{ name = "type_params", type = "TypeParams?" },
|
||||
{ name = "type_params", type = "Box<crate::TypeParams>?" },
|
||||
{ name = "value", type = "Expr" },
|
||||
]
|
||||
|
||||
|
||||
2
crates/ruff_python_ast/src/generated.rs
generated
2
crates/ruff_python_ast/src/generated.rs
generated
@@ -6494,7 +6494,7 @@ pub struct StmtDelete {
|
||||
pub struct StmtTypeAlias {
|
||||
pub range: ruff_text_size::TextRange,
|
||||
pub name: Box<Expr>,
|
||||
pub type_params: Option<crate::TypeParams>,
|
||||
pub type_params: Option<Box<crate::TypeParams>>,
|
||||
pub value: Box<Expr>,
|
||||
}
|
||||
|
||||
|
||||
@@ -1622,10 +1622,10 @@ mod tests {
|
||||
});
|
||||
let type_alias = Stmt::TypeAlias(StmtTypeAlias {
|
||||
name: Box::new(name.clone()),
|
||||
type_params: Some(TypeParams {
|
||||
type_params: Some(Box::new(TypeParams {
|
||||
type_params: vec![type_var_one, type_var_two],
|
||||
range: TextRange::default(),
|
||||
}),
|
||||
})),
|
||||
value: Box::new(constant_three.clone()),
|
||||
range: TextRange::default(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user