mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(linter/no-unused-vars): panic in variable declarator usage checks (#5160)
Part of #5129
This commit is contained in:
parent
e3561127fe
commit
36e4a2875c
1 changed files with 3 additions and 9 deletions
|
|
@ -333,12 +333,9 @@ impl<'s, 'a> Symbol<'s, 'a> {
|
|||
match node.kind() {
|
||||
// references used in declaration of another variable are definitely
|
||||
// used by others
|
||||
AstKind::VariableDeclarator(v) => {
|
||||
// let a = a; is a static semantic error, even if `a` is shadowed.
|
||||
debug_assert!(
|
||||
v.id.kind.get_identifier().map_or_else(|| true, |id| id != name),
|
||||
"While traversing {name}'s reference's parent nodes, found {name}'s declaration. This algorithm assumes that variable declarations do not appear in references."
|
||||
);
|
||||
AstKind::VariableDeclarator(_)
|
||||
| AstKind::JSXExpressionContainer(_)
|
||||
| AstKind::Argument(_) => {
|
||||
// definitely used, short-circuit
|
||||
return false;
|
||||
}
|
||||
|
|
@ -382,9 +379,6 @@ impl<'s, 'a> Symbol<'s, 'a> {
|
|||
| AstKind::WhileStatement(_) => {
|
||||
break;
|
||||
}
|
||||
AstKind::JSXExpressionContainer(_) | AstKind::Argument(_) => {
|
||||
return false;
|
||||
}
|
||||
// this is needed to handle `return () => foo++`
|
||||
AstKind::ExpressionStatement(_) => {
|
||||
if self.is_in_return_statement(node.id()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue