diff --git a/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs b/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs index 5a72b63c7..52ba81ac8 100644 --- a/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs +++ b/crates/oxc_linter/src/rules/eslint/no_obj_calls.rs @@ -88,11 +88,13 @@ fn resolve_global_binding<'a, 'b: 'a>( let scope = ctx.scopes(); let nodes = ctx.nodes(); let symbols = ctx.symbols(); - scope.get_binding(scope_id, &ident.name).map_or_else( + scope.ancestors(scope_id).find_map(|id| scope.get_binding(id, &ident.name)).map_or_else( || { - // panic!("No binding id found for {}, but this IdentifierReference - // is not a global", &ident.name); - None + panic!( + "No binding id found for {}, but this IdentifierReference + is not a global", + &ident.name + ); }, |binding_id| { let decl = nodes.get_node(symbols.get_declaration(binding_id)); @@ -174,6 +176,8 @@ fn test() { }", None, ), + // https://github.com/web-infra-dev/oxc/pull/508#issuecomment-1618850742 + ("{const Math = () => {}; {let obj = new Math();}}", None), ]; let fail = vec![