From baf4903aa7c36bd614d3547403d6794bf77ab472 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 3 Oct 2020 00:02:28 +0100 Subject: fix corner cases of `catch` variable inlining (#4169) --- test/compress/ie8.js | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) (limited to 'test/compress/ie8.js') diff --git a/test/compress/ie8.js b/test/compress/ie8.js index 6c0aa9e8..4d74d44e 100644 --- a/test/compress/ie8.js +++ b/test/compress/ie8.js @@ -2714,3 +2714,108 @@ issue_2737: { } expect_stdout: "function" } + +single_use_catch_redefined: { + options = { + ie8: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var a = 1; + try { + throw 2; + } catch (a) { + function g() { + return a; + } + } + console.log(g()); + } + expect: { + var a = 1; + try { + throw 2; + } catch (a) { + function g() { + return a; + } + } + console.log(g()); + } + expect_stdout: true +} + +single_use_inline_catch_redefined: { + options = { + ie8: true, + inline: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + var a = 1; + try { + throw 2; + } catch (a) { + function g() { + return a; + } + } + console.log(g()); + } + expect: { + var a = 1; + try { + throw 2; + } catch (a) { + function g() { + return a; + } + } + console.log(g()); + } + expect_stdout: true +} + +direct_inline_catch_redefined: { + options = { + ie8: true, + inline: true, + reduce_vars: true, + toplevel: true, + } + input: { + var a = 1; + function f() { + return a; + } + try { + throw 2; + } catch (a) { + function g() { + return a; + } + console.log(a, f(), g()); + } + console.log(a, f(), g()); + } + expect: { + var a = 1; + function f() { + return a; + } + try { + throw 2; + } catch (a) { + function g() { + return a; + } + console.log(a, f(), g()); + } + console.log(a, a, g()); + } + expect_stdout: true +} -- cgit v1.2.3