From f8f6d33722952f1a999b22af3b4eecd9b48f3ffb Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:57:56 +0000 Subject: [PATCH] fix(ast): correct `visited_node` attr for strict mode of arrow fns (#3635) Correct the `#[visited_node]` attr on `ArrowFunctionExpression` to recognise strict mode functions. This change has no effect at present as `Traverse` codegen currently ignores `strict_if`. But useful for it to be correct for if we codegen `Visit` / `VisitMut` later on (#3392). --- crates/oxc_ast/src/ast/js.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 531ca88a2..39610e026 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -2523,7 +2523,10 @@ impl<'a> FunctionBody<'a> { } /// Arrow Function Definitions -#[visited_node(scope(ScopeFlags::Function | ScopeFlags::Arrow))] +#[visited_node( + scope(ScopeFlags::Function | ScopeFlags::Arrow), + strict_if(self.body.has_use_strict_directive()) +)] #[derive(Debug)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] #[cfg_attr(feature = "serialize", serde(tag = "type", rename_all = "camelCase"))]