From 94f1f85d4ea40344064a7524f85e6cc4d271f0d4 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 11:29:27 +0900 Subject: [PATCH 01/14] More assertions --- crates/swc_ecma_minifier/src/compress/optimize/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index d4a636ce6daf..481ad8da1ea0 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -2114,6 +2114,9 @@ where }); drop_invalid_stmts(stmts); + + debug_assert_eq!(self.prepend_stmts, vec![]); + debug_assert_eq!(self.append_stmts, vec![]); } fn visit_mut_new_expr(&mut self, n: &mut NewExpr) { From 2c9a1a5e85334d2865968e0f4607233407114982 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 11:33:23 +0900 Subject: [PATCH 02/14] More assertions --- .../src/compress/optimize/mod.rs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 481ad8da1ea0..3da29dabd226 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -2361,6 +2361,8 @@ where self.prepend_stmts = old_prepend; self.append_stmts = old_append; + let len = self.prepend_stmts.len(); + if cfg!(feature = "debug") && self.debug_infinite_loop { let text = dump(&*s, false); @@ -2369,6 +2371,8 @@ where } } + debug_assert_eq!(self.prepend_stmts.len(), len); + if let Stmt::Expr(ExprStmt { expr, .. }) = s { if is_pure_undefined(expr) { *s = Stmt::Empty(EmptyStmt { span: DUMMY_SP }); @@ -2405,6 +2409,8 @@ where } } + debug_assert_eq!(self.prepend_stmts.len(), len); + match s { // We use var decl with no declarator to indicate we dropped an decl. Stmt::Decl(Decl::Var(VarDecl { decls, .. })) if decls.is_empty() => { @@ -2414,20 +2420,34 @@ where _ => {} } + debug_assert_eq!(self.prepend_stmts.len(), len); + if cfg!(debug_assertions) { s.visit_with(&mut AssertValid); } + debug_assert_eq!(self.prepend_stmts.len(), len); + self.compress_if_without_alt(s); + debug_assert_eq!(self.prepend_stmts.len(), len); + self.compress_if_stmt_as_cond(s); + debug_assert_eq!(self.prepend_stmts.len(), len); + self.compress_if_stmt_as_expr(s); + debug_assert_eq!(self.prepend_stmts.len(), len); + self.optimize_const_switches(s); + debug_assert_eq!(self.prepend_stmts.len(), len); + self.optimize_switches(s); + debug_assert_eq!(self.prepend_stmts.len(), len); + if cfg!(feature = "debug") && self.debug_infinite_loop { let text = dump(&*s, false); @@ -2436,9 +2456,13 @@ where } } + debug_assert_eq!(self.prepend_stmts.len(), len); + if cfg!(debug_assertions) { s.visit_with(&mut AssertValid); } + + debug_assert_eq!(self.prepend_stmts.len(), len); } fn visit_mut_stmts(&mut self, stmts: &mut Vec) { From acbe4227c1850856a399e2b9f6798984a12f618e Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 11:56:04 +0900 Subject: [PATCH 03/14] More log --- crates/swc_ecma_minifier/src/compress/optimize/iife.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs index db3f316e1f49..c567e26728ac 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs @@ -616,6 +616,9 @@ where .collect::>(); if !vars.is_empty() { + if cfg!(feature = "debug") { + tracing::debug!("iife: Creating variables"); + } self.prepend_stmts.push(Stmt::Decl(Decl::Var(VarDecl { span: DUMMY_SP.apply_mark(self.marks.non_top_level), kind: VarDeclKind::Var, From 06d2812a0013b266204dee7e3aec062d2e56422f Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 11:56:59 +0900 Subject: [PATCH 04/14] fixup --- crates/swc_ecma_minifier/src/compress/optimize/iife.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs index c567e26728ac..88dabd62263e 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs @@ -617,7 +617,7 @@ where if !vars.is_empty() { if cfg!(feature = "debug") { - tracing::debug!("iife: Creating variables"); + tracing::debug!("iife: Creating variables: {:?}", vars); } self.prepend_stmts.push(Stmt::Decl(Decl::Var(VarDecl { span: DUMMY_SP.apply_mark(self.marks.non_top_level), From 6a18b68c7f920a80e589cf37d0cd2a7e43d415b4 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 11:59:29 +0900 Subject: [PATCH 05/14] More context --- crates/swc_ecma_minifier/src/compress/optimize/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 3da29dabd226..4642868f9376 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -1777,6 +1777,7 @@ where n.visit_mut_children_with(&mut *self.with_ctx(ctx)); } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, e)))] fn visit_mut_expr(&mut self, e: &mut Expr) { let ctx = Ctx { is_exported: false, @@ -1848,6 +1849,7 @@ where } } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n)))] fn visit_mut_expr_stmt(&mut self, n: &mut ExprStmt) { n.visit_mut_children_with(self); @@ -1977,6 +1979,7 @@ where self.with_ctx(ctx).drop_if_break(s); } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n)))] fn visit_mut_function(&mut self, n: &mut Function) { { let ctx = Ctx { @@ -2270,6 +2273,7 @@ where self.lift_seqs_of_assign(n); } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, s)))] fn visit_mut_stmt(&mut self, s: &mut Stmt) { let old_prepend = self.prepend_stmts.take(); let old_append = self.append_stmts.take(); From f2f78c97a9b79d09fbf0c3f2b4c390bc7d4e1be9 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 12:04:51 +0900 Subject: [PATCH 06/14] More context --- crates/swc_ecma_minifier/src/compress/optimize/iife.rs | 2 ++ crates/swc_ecma_minifier/src/compress/optimize/mod.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs index 88dabd62263e..029aee21bbac 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs @@ -137,6 +137,7 @@ where /// })(x); /// })(7); /// ``` + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, e)))] pub(super) fn inline_args_of_iife(&mut self, e: &mut CallExpr) { if self.options.inline == 0 { return; @@ -250,6 +251,7 @@ where } } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n, vars)))] pub(super) fn inline_vars_in_node(&mut self, n: &mut N, vars: AHashMap>) where N: VisitMutWith, diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 4642868f9376..5620fcdf0687 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -1535,6 +1535,7 @@ where { noop_visit_mut_type!(); + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n,)))] fn visit_mut_arrow_expr(&mut self, n: &mut ArrowExpr) { let prepend = self.prepend_stmts.take(); @@ -1575,6 +1576,7 @@ where } } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, e)))] fn visit_mut_assign_expr(&mut self, e: &mut AssignExpr) { { let ctx = Ctx { @@ -1594,6 +1596,7 @@ where self.compress_bin_assignment_to_right(e); } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n)))] fn visit_mut_assign_pat_prop(&mut self, n: &mut AssignPatProp) { n.visit_mut_children_with(self); @@ -1604,6 +1607,7 @@ where } } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n)))] fn visit_mut_bin_expr(&mut self, n: &mut BinExpr) { { let ctx = Ctx { From 0114246842b5200cd526669eeab3e3669cacce70 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 12:05:00 +0900 Subject: [PATCH 07/14] fixup --- crates/swc_ecma_minifier/src/compress/optimize/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 5620fcdf0687..272a0ed15e1e 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -1635,6 +1635,7 @@ where } } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n)))] fn visit_mut_block_stmt(&mut self, n: &mut BlockStmt) { let ctx = Ctx { stmt_labelled: false, From ec7f62988e0d2eb522ae8d65276fb52d90b96512 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 12:06:30 +0900 Subject: [PATCH 08/14] More context --- crates/swc_ecma_minifier/src/compress/optimize/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 272a0ed15e1e..d2b0e5a2ced8 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -1659,6 +1659,7 @@ where } } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, e)))] fn visit_mut_call_expr(&mut self, e: &mut CallExpr) { let is_this_undefined = match &e.callee { Callee::Super(_) | Callee::Import(_) => false, @@ -1708,6 +1709,7 @@ where self.inline_args_of_iife(e); } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n)))] fn visit_mut_class(&mut self, n: &mut Class) { n.decorators.visit_mut_with(self); @@ -1736,6 +1738,7 @@ where e.visit_mut_children_with(self); } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, decl)))] fn visit_mut_decl(&mut self, decl: &mut Decl) { decl.visit_mut_children_with(self); @@ -1744,6 +1747,7 @@ where self.store_decl_for_inlining(decl); } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n)))] fn visit_mut_default_decl(&mut self, n: &mut DefaultDecl) { match n { DefaultDecl::Class(_) => {} @@ -1758,6 +1762,7 @@ where n.visit_mut_children_with(self); } + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, n)))] fn visit_mut_export_decl(&mut self, n: &mut ExportDecl) { if let Decl::Fn(f) = &mut n.decl { // I don't know why, but terser removes parameters from an exported function if From 6ef9fdaa92164c7da9b1a44598cf1de6b0872cd9 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 12:16:56 +0900 Subject: [PATCH 09/14] Add an assertion --- .../src/compress/optimize/mod.rs | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index d2b0e5a2ced8..6d5910237f9c 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -188,9 +188,9 @@ struct Optimizer<'a, M> { options: &'a CompressOptions, /// Statements prepended to the current statement. - prepend_stmts: Vec, + prepend_stmts: SynthesizedStmts, /// Statements appended to the current statement. - append_stmts: Vec, + append_stmts: SynthesizedStmts, /// Cheap to clone. /// @@ -1563,7 +1563,7 @@ where })); n.body = BlockStmtOrExpr::BlockStmt(BlockStmt { span: DUMMY_SP, - stmts, + stmts: stmts.0, }); } } @@ -2127,9 +2127,6 @@ where }); drop_invalid_stmts(stmts); - - debug_assert_eq!(self.prepend_stmts, vec![]); - debug_assert_eq!(self.append_stmts, vec![]); } fn visit_mut_new_expr(&mut self, n: &mut NewExpr) { @@ -2784,3 +2781,34 @@ fn is_left_access_to_arguments(l: &PatOrExpr) -> bool { }, } } + +#[derive(Debug, Default, PartialEq)] +struct SynthesizedStmts(Vec); + +impl std::ops::Deref for SynthesizedStmts { + type Target = Vec; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl std::ops::DerefMut for SynthesizedStmts { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +impl Take for SynthesizedStmts { + fn dummy() -> Self { + Self(Take::dummy()) + } +} + +impl Drop for SynthesizedStmts { + fn drop(&mut self) { + if !self.0.is_empty() { + panic!("We should not drop synthesized stmts"); + } + } +} From a05d312288a9470a5245751923a24ea35096f64e Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 12:22:30 +0900 Subject: [PATCH 10/14] Add a type for assertion --- .../swc_ecma_minifier/src/compress/optimize/mod.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 6d5910237f9c..37424f97eaa5 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -1547,7 +1547,7 @@ where n.visit_mut_children_with(&mut *self.with_ctx(ctx)); if !self.prepend_stmts.is_empty() { - let mut stmts = self.prepend_stmts.take(); + let mut stmts = self.prepend_stmts.take().into_stmts(); match &mut n.body { BlockStmtOrExpr::BlockStmt(v) => { prepend_stmts(&mut v.stmts, stmts.into_iter()); @@ -1563,7 +1563,7 @@ where })); n.body = BlockStmtOrExpr::BlockStmt(BlockStmt { span: DUMMY_SP, - stmts: stmts.0, + stmts, }); } } @@ -2352,10 +2352,10 @@ where span: span.apply_mark(self.marks.fake_block), stmts: self .prepend_stmts - .take() + .into_stmts() .into_iter() .chain(once(s.take())) - .chain(self.append_stmts.take().into_iter()) + .chain(self.append_stmts.into_stmts().into_iter()) .filter(|s| match s { Stmt::Empty(..) => false, Stmt::Decl(Decl::Var(v)) => !v.decls.is_empty(), @@ -2785,6 +2785,12 @@ fn is_left_access_to_arguments(l: &PatOrExpr) -> bool { #[derive(Debug, Default, PartialEq)] struct SynthesizedStmts(Vec); +impl SynthesizedStmts { + fn into_stmts(&mut self) -> Vec { + take(&mut self.0) + } +} + impl std::ops::Deref for SynthesizedStmts { type Target = Vec; From a44dd274d91083041ce251766ee562c9f97e805b Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 12:27:42 +0900 Subject: [PATCH 11/14] Rename --- crates/swc_ecma_minifier/src/compress/optimize/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 37424f97eaa5..e2d8609720eb 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -1547,7 +1547,7 @@ where n.visit_mut_children_with(&mut *self.with_ctx(ctx)); if !self.prepend_stmts.is_empty() { - let mut stmts = self.prepend_stmts.take().into_stmts(); + let mut stmts = self.prepend_stmts.take().take_stmts(); match &mut n.body { BlockStmtOrExpr::BlockStmt(v) => { prepend_stmts(&mut v.stmts, stmts.into_iter()); @@ -2352,10 +2352,10 @@ where span: span.apply_mark(self.marks.fake_block), stmts: self .prepend_stmts - .into_stmts() + .take_stmts() .into_iter() .chain(once(s.take())) - .chain(self.append_stmts.into_stmts().into_iter()) + .chain(self.append_stmts.take_stmts().into_iter()) .filter(|s| match s { Stmt::Empty(..) => false, Stmt::Decl(Decl::Var(v)) => !v.decls.is_empty(), @@ -2786,7 +2786,7 @@ fn is_left_access_to_arguments(l: &PatOrExpr) -> bool { struct SynthesizedStmts(Vec); impl SynthesizedStmts { - fn into_stmts(&mut self) -> Vec { + fn take_stmts(&mut self) -> Vec { take(&mut self.0) } } From 2f07b3c0d9e00c56723b92fdc0ad9edf98ad76a2 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 12:42:32 +0900 Subject: [PATCH 12/14] More log --- crates/swc_ecma_minifier/src/compress/optimize/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index e2d8609720eb..4859d0e028c9 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -239,6 +239,7 @@ impl Optimizer<'_, M> where M: Mode, { + #[cfg_attr(feature = "debug", tracing::instrument(skip(self, stmts)))] fn handle_stmt_likes(&mut self, stmts: &mut Vec) where T: StmtLike + ModuleItemLike + ModuleItemExt + VisitMutWith, From a47d1d89c74911037a44d54b92ae6a29382b5c30 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 12:44:12 +0900 Subject: [PATCH 13/14] Fix? --- .../swc_ecma_minifier/src/compress/optimize/mod.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 4859d0e028c9..e92d02374e8e 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -252,8 +252,8 @@ where } } let mut use_asm = false; - // let prepend_stmts = self.prepend_stmts.take(); - // let append_stmts = self.append_stmts.take(); + let prepend_stmts = self.prepend_stmts.take(); + let append_stmts = self.append_stmts.take(); { let mut child_ctx = Ctx { ..self.ctx }; @@ -290,6 +290,8 @@ where stmt.visit_mut_with(&mut *self.with_ctx(child_ctx)); } + new.extend(self.prepend_stmts.drain(..).map(T::from_stmt)); + match stmt.try_into_stmt() { Ok(Stmt::Block(s)) if s.span.has_mark(self.marks.fake_block) => { new.extend(s.stmts.into_iter().map(T::from_stmt)); @@ -302,8 +304,7 @@ where } } - // new.extend(self.prepend_stmts.drain(..).map(T::from_stmt)); - // new.extend(self.append_stmts.drain(..).map(T::from_stmt)); + new.extend(self.append_stmts.drain(..).map(T::from_stmt)); } *stmts = new; } @@ -361,8 +362,8 @@ where drop_invalid_stmts(stmts); // debug_assert_eq!(self.prepend_stmts, vec![]); - // self.prepend_stmts = prepend_stmts; - // self.append_stmts = append_stmts; + self.prepend_stmts = prepend_stmts; + self.append_stmts = append_stmts; } /// `a = a + 1` => `a += 1`. From 4bdf68f082847ae2fb8158d53648313f5d2aef79 Mon Sep 17 00:00:00 2001 From: Donny Date: Wed, 26 Jan 2022 12:48:00 +0900 Subject: [PATCH 14/14] Update test refs --- .../arrowFunctionExpressions_es5.2.minified.js | 6 +----- .../tests/tsc-references/exportCodeGen_es5.2.minified.js | 4 ++-- ...loadedMethodWithOverloadedArguments_es2015.2.minified.js | 4 ++-- ...verloadedMethodWithOverloadedArguments_es5.2.minified.js | 4 ++-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/swc/tests/tsc-references/arrowFunctionExpressions_es5.2.minified.js b/crates/swc/tests/tsc-references/arrowFunctionExpressions_es5.2.minified.js index 3de98dd68dbc..4f0a459e0f4f 100644 --- a/crates/swc/tests/tsc-references/arrowFunctionExpressions_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/arrowFunctionExpressions_es5.2.minified.js @@ -24,10 +24,6 @@ var MyClass = function() { } ], _defineProperties((Constructor = MyClass).prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), MyClass; }(); -(m = 3, function() { - return function(n) { - return 3 + n; - }; -})()(4), (function() { +(function() { return 0; })().toExponential(); diff --git a/crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js b/crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js index 749309c527ef..39b8720194fc 100644 --- a/crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/exportCodeGen_es5.2.minified.js @@ -1,8 +1,8 @@ -var A1, D, E, F; +var A, D, E, F; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } -(A = A1 || (A1 = {})).x = 12, (D || (D = {})).yes = function() { +(A || (A = {})).x = 12, (D || (D = {})).yes = function() { return !0; }, (function(E1) { (Color = Color = E1.Color || (E1.Color = {}))[Color.Red = 0] = "Red", E1.fn = function() {}; diff --git a/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments_es2015.2.minified.js b/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments_es2015.2.minified.js index d2ec46bb8deb..1d2935931449 100644 --- a/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments_es2015.2.minified.js @@ -1,2 +1,2 @@ -var m11, m21, m31, m41, m51, m6; -m1 = m11 || (m11 = {}), (void 0).then(testFunction), m2 = m21 || (m21 = {}), (void 0).then(testFunction), m3 = m31 || (m31 = {}), (void 0).then(testFunction), m4 = m41 || (m41 = {}), (void 0).then(testFunction), m5 = m51 || (m51 = {}), (void 0).then(testFunction), m6 || (m6 = {}), (void 0).then(testFunction); +var m1, m2, m3, m4, m5, m6; +m1 || (m1 = {}), (void 0).then(testFunction), m2 || (m2 = {}), (void 0).then(testFunction), m3 || (m3 = {}), (void 0).then(testFunction), m4 || (m4 = {}), (void 0).then(testFunction), m5 || (m5 = {}), (void 0).then(testFunction), m6 || (m6 = {}), (void 0).then(testFunction); diff --git a/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments_es5.2.minified.js b/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments_es5.2.minified.js index d2ec46bb8deb..1d2935931449 100644 --- a/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/genericCallToOverloadedMethodWithOverloadedArguments_es5.2.minified.js @@ -1,2 +1,2 @@ -var m11, m21, m31, m41, m51, m6; -m1 = m11 || (m11 = {}), (void 0).then(testFunction), m2 = m21 || (m21 = {}), (void 0).then(testFunction), m3 = m31 || (m31 = {}), (void 0).then(testFunction), m4 = m41 || (m41 = {}), (void 0).then(testFunction), m5 = m51 || (m51 = {}), (void 0).then(testFunction), m6 || (m6 = {}), (void 0).then(testFunction); +var m1, m2, m3, m4, m5, m6; +m1 || (m1 = {}), (void 0).then(testFunction), m2 || (m2 = {}), (void 0).then(testFunction), m3 || (m3 = {}), (void 0).then(testFunction), m4 || (m4 = {}), (void 0).then(testFunction), m5 || (m5 = {}), (void 0).then(testFunction), m6 || (m6 = {}), (void 0).then(testFunction);