Skip to content

Commit 36e4a28

Browse files
committedAug 24, 2024·
fix(linter/no-unused-vars): panic in variable declarator usage checks (#5160)
Part of #5129
1 parent e356112 commit 36e4a28

File tree

1 file changed

+3
-9
lines changed
  • crates/oxc_linter/src/rules/eslint/no_unused_vars

1 file changed

+3
-9
lines changed
 

‎crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,9 @@ impl<'s, 'a> Symbol<'s, 'a> {
333333
match node.kind() {
334334
// references used in declaration of another variable are definitely
335335
// used by others
336-
AstKind::VariableDeclarator(v) => {
337-
// let a = a; is a static semantic error, even if `a` is shadowed.
338-
debug_assert!(
339-
v.id.kind.get_identifier().map_or_else(|| true, |id| id != name),
340-
"While traversing {name}'s reference's parent nodes, found {name}'s declaration. This algorithm assumes that variable declarations do not appear in references."
341-
);
336+
AstKind::VariableDeclarator(_)
337+
| AstKind::JSXExpressionContainer(_)
338+
| AstKind::Argument(_) => {
342339
// definitely used, short-circuit
343340
return false;
344341
}
@@ -382,9 +379,6 @@ impl<'s, 'a> Symbol<'s, 'a> {
382379
| AstKind::WhileStatement(_) => {
383380
break;
384381
}
385-
AstKind::JSXExpressionContainer(_) | AstKind::Argument(_) => {
386-
return false;
387-
}
388382
// this is needed to handle `return () => foo++`
389383
AstKind::ExpressionStatement(_) => {
390384
if self.is_in_return_statement(node.id()) {

0 commit comments

Comments
 (0)
Please sign in to comment.