diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index efb72a22e543a..a6174ece6d9c3 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -1701,7 +1701,7 @@ pub struct FunctionBody<'a> { #[ast(visit)] #[scope( flags(ScopeFlags::Function | ScopeFlags::Arrow), - strict_if(self.body.has_use_strict_directive()), + strict_if(self.has_use_strict_directive()), )] #[derive(Debug)] #[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ContentHash, ESTree)] diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index dacdec4f3f762..8db452837d298 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -1094,6 +1094,11 @@ impl<'a> ArrowFunctionExpression<'a> { } None } + + /// Returns `true` if this arrow function's body has a `"use strict"` directive. + pub fn has_use_strict_directive(&self) -> bool { + self.body.has_use_strict_directive() + } } impl Class<'_> { diff --git a/crates/oxc_ast/src/generated/visit.rs b/crates/oxc_ast/src/generated/visit.rs index 24457baff52ab..70da037f4e882 100644 --- a/crates/oxc_ast/src/generated/visit.rs +++ b/crates/oxc_ast/src/generated/visit.rs @@ -1684,7 +1684,7 @@ pub mod walk { visitor.enter_scope( { let mut flags = ScopeFlags::Function | ScopeFlags::Arrow; - if it.body.has_use_strict_directive() { + if it.has_use_strict_directive() { flags |= ScopeFlags::StrictMode; } flags diff --git a/crates/oxc_ast/src/generated/visit_mut.rs b/crates/oxc_ast/src/generated/visit_mut.rs index e23a8a672ae58..43615f86320b1 100644 --- a/crates/oxc_ast/src/generated/visit_mut.rs +++ b/crates/oxc_ast/src/generated/visit_mut.rs @@ -1703,7 +1703,7 @@ pub mod walk_mut { visitor.enter_scope( { let mut flags = ScopeFlags::Function | ScopeFlags::Arrow; - if it.body.has_use_strict_directive() { + if it.has_use_strict_directive() { flags |= ScopeFlags::StrictMode; } flags