From 581630e0a71cffeadd4887a757889d6a3502275c Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 27 Mar 2017 04:37:42 +0800 Subject: fix typeof side effects (#1696) `statement_to_expression()` drops `typeof` even if it operates on undeclared variables. Since we now have `drop_side_effect_free()`, replace and remove this deprecated functionality. --- test/compress/negate-iife.js | 9 +++++---- test/compress/switch.js | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'test/compress') diff --git a/test/compress/negate-iife.js b/test/compress/negate-iife.js index e9ad37db..343e8e16 100644 --- a/test/compress/negate-iife.js +++ b/test/compress/negate-iife.js @@ -353,8 +353,9 @@ issue_1254_negate_iife_nested: { issue_1288: { options = { - negate_iife: true, conditionals: true, + negate_iife: true, + side_effects: false, }; input: { if (w) ; @@ -374,11 +375,11 @@ issue_1288: { })(0); } expect: { - w || function f() {}(); - x || function() { + w || !function f() {}(); + x || !function() { x = {}; }(); - y ? function() {}() : function(z) { + y ? !function() {}() : !function(z) { return z; }(0); } diff --git a/test/compress/switch.js b/test/compress/switch.js index 654a838b..c3e76302 100644 --- a/test/compress/switch.js +++ b/test/compress/switch.js @@ -579,3 +579,17 @@ issue_1690_2: { } expect_stdout: "PASS" } + +if_switch_typeof: { + options = { + conditionals: true, + dead_code: true, + side_effects: true, + } + input: { + if (a) switch(typeof b) {} + } + expect: { + a; + } +} -- cgit v1.2.3