diff --git a/crates/oxc_codegen/tests/integration/snapshots/pure_comments.snap b/crates/oxc_codegen/tests/integration/snapshots/pure_comments.snap index 8c9b21057fb73..d722e614adf86 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/pure_comments.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/pure_comments.snap @@ -155,11 +155,11 @@ export default function() {} /* #__NO_SIDE_EFFECTS__ */ export const c2 = () => {}, c3 = () => {} ---------- -export var v0 = /* @__NO_SIDE_EFFECTS__ */ function() {}, v1 = function() {}; -export let l0 = /* @__NO_SIDE_EFFECTS__ */ function() {}, l1 = function() {}; +export var v0 = function() {}, v1 = function() {}; +export let l0 = function() {}, l1 = function() {}; export const c0 = /* @__NO_SIDE_EFFECTS__ */ function() {}, c1 = function() {}; -export var v2 = /* @__NO_SIDE_EFFECTS__ */ () => {}, v3 = () => {}; -export let l2 = /* @__NO_SIDE_EFFECTS__ */ () => {}, l3 = () => {}; +export var v2 = () => {}, v3 = () => {}; +export let l2 = () => {}, l3 = () => {}; export const c2 = /* @__NO_SIDE_EFFECTS__ */ () => {}, c3 = () => {}; ########## 8 @@ -172,11 +172,11 @@ export const c2 = /* @__NO_SIDE_EFFECTS__ */ () => {}, c3 = () => {}; /* #__NO_SIDE_EFFECTS__ */ const c2 = () => {}, c3 = () => {} ---------- -var v0 = /* @__NO_SIDE_EFFECTS__ */ function() {}, v1 = function() {}; -let l0 = /* @__NO_SIDE_EFFECTS__ */ function() {}, l1 = function() {}; +var v0 = function() {}, v1 = function() {}; +let l0 = function() {}, l1 = function() {}; const c0 = /* @__NO_SIDE_EFFECTS__ */ function() {}, c1 = function() {}; -var v2 = /* @__NO_SIDE_EFFECTS__ */ () => {}, v3 = () => {}; -let l2 = /* @__NO_SIDE_EFFECTS__ */ () => {}, l3 = () => {}; +var v2 = () => {}, v3 = () => {}; +let l2 = () => {}, l3 = () => {}; const c2 = /* @__NO_SIDE_EFFECTS__ */ () => {}, c3 = () => {}; ########## 9 diff --git a/crates/oxc_parser/src/js/statement.rs b/crates/oxc_parser/src/js/statement.rs index 643de0c725cb1..bfe0fb24010c7 100644 --- a/crates/oxc_parser/src/js/statement.rs +++ b/crates/oxc_parser/src/js/statement.rs @@ -161,7 +161,7 @@ impl<'a> ParserImpl<'a> { Some(Declaration::FunctionDeclaration(func)) => { func.pure = true; } - Some(Declaration::VariableDeclaration(var_decl)) => { + Some(Declaration::VariableDeclaration(var_decl)) if var_decl.kind.is_const() => { if let Some(Some(expr)) = var_decl.declarations.first_mut().map(|d| &mut d.init) { Self::set_pure_on_function_expr(expr); @@ -169,7 +169,7 @@ impl<'a> ParserImpl<'a> { } _ => {} }, - Statement::VariableDeclaration(var_decl) => { + Statement::VariableDeclaration(var_decl) if var_decl.kind.is_const() => { if let Some(Some(expr)) = var_decl.declarations.first_mut().map(|d| &mut d.init) { Self::set_pure_on_function_expr(expr); }