11use std:: ops:: Deref ;
22
3+ use oxc_allocator:: { Address , GetAddress } ;
34use oxc_ast:: {
45 AstKind ,
56 ast:: { Argument , ArrowFunctionExpression , Expression , Function } ,
67} ;
78use oxc_diagnostics:: { LabeledSpan , OxcDiagnostic } ;
89use oxc_macros:: declare_oxc_lint;
910use oxc_span:: { CompactStr , Span } ;
11+ use rustc_hash:: FxHashSet ;
1012use serde_json:: Value ;
1113
1214use crate :: { AstNode , context:: LintContext , rule:: Rule , utils} ;
@@ -199,7 +201,8 @@ impl Rule for NoAsyncEndpointHandlers {
199201
200202impl NoAsyncEndpointHandlers {
201203 fn check_endpoint_arg < ' a > ( & self , ctx : & LintContext < ' a > , arg : & Expression < ' a > ) {
202- self . check_endpoint_expr ( ctx, None , None , arg) ;
204+ let mut visited = FxHashSet :: default ( ) ;
205+ self . check_endpoint_expr ( ctx, None , None , arg, & mut visited) ;
203206 }
204207
205208 fn check_endpoint_expr < ' a > (
@@ -208,7 +211,13 @@ impl NoAsyncEndpointHandlers {
208211 id_name : Option < & str > ,
209212 registered_at : Option < Span > ,
210213 arg : & Expression < ' a > ,
214+ visited : & mut FxHashSet < Address > ,
211215 ) {
216+ let expr_ptr = arg. address ( ) ;
217+ if !visited. insert ( expr_ptr) {
218+ return ;
219+ }
220+
212221 match arg {
213222 Expression :: Identifier ( handler) => {
214223 // Unresolved reference? Nothing we can do.
@@ -240,7 +249,7 @@ impl NoAsyncEndpointHandlers {
240249 return ;
241250 }
242251 }
243- self . check_endpoint_expr ( ctx, id_name, registered_at, init) ;
252+ self . check_endpoint_expr ( ctx, id_name, registered_at, init, visited ) ;
244253 }
245254 }
246255 _ => { }
@@ -351,6 +360,7 @@ fn test() {
351360 " ,
352361 None ,
353362 ) ,
363+ ( "{const{r}=r;e.delete(r)}" , None ) ,
354364 ] ;
355365
356366 let fail = vec ! [
0 commit comments