Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ast): add ArrowFunctionExpression::has_use_strict_directive method #7784

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
5 changes: 5 additions & 0 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_> {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading