diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 559624e2c9b3d..6a4f7809bb3fa 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -2136,7 +2136,7 @@ pub struct BindingRestElement<'a> { // Don't create scope if this is a method - `MethodDefinition` already created one. // `ctx.ancestor(2).unwrap()` not `ctx.parent()` because this code is inserted // into `walk_function` *after* `Function` is added to stack. - scope_if(matches!(ctx.ancestor(2).unwrap(), Ancestor::MethodDefinitionValue(_))), + scope_if(!matches!(ctx.ancestor(2).unwrap(), Ancestor::MethodDefinitionValue(_))), strict_if(self.body.as_ref().is_some_and(|body| body.has_use_strict_directive())) )] #[derive(Debug, Hash)] diff --git a/crates/oxc_traverse/src/walk.rs b/crates/oxc_traverse/src/walk.rs index f6c6792c35e4d..449735ac5cad0 100644 --- a/crates/oxc_traverse/src/walk.rs +++ b/crates/oxc_traverse/src/walk.rs @@ -2228,7 +2228,7 @@ pub(crate) unsafe fn walk_function<'a, Tr: Traverse<'a>>( ) { traverser.enter_function(&mut *node, ctx); ctx.push_stack(Ancestor::FunctionId(ancestor::FunctionWithoutId(node))); - let has_scope = matches!(ctx.ancestor(2).unwrap(), Ancestor::MethodDefinitionValue(_)); + let has_scope = !matches!(ctx.ancestor(2).unwrap(), Ancestor::MethodDefinitionValue(_)); if has_scope { ctx.push_scope_stack( ScopeFlags::Function.with_strict_mode(