[Pkg-javascript-commits] [uglifyjs] 07/491: fix `reduce_vars` within try-block (#1818)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:51:17 UTC 2018
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.
commit 71a8d0d236d29015df2d1df18de11d661d17af2e
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Mon Apr 17 14:03:29 2017 +0800
fix `reduce_vars` within try-block (#1818)
Possible partial execution due to exceptions.
---
lib/compress.js | 14 +++++++++++++-
test/compress/reduce_vars.js | 31 +++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/lib/compress.js b/lib/compress.js
index 640fcec..cc42c46 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -382,7 +382,19 @@ merge(Compressor.prototype, {
pop();
return true;
}
- if (node instanceof AST_Catch || node instanceof AST_SwitchBranch) {
+ if (node instanceof AST_Try) {
+ push();
+ walk_body(node, tw);
+ pop();
+ if (node.bcatch) {
+ push();
+ node.bcatch.walk(tw);
+ pop();
+ }
+ if (node.bfinally) node.bfinally.walk(tw);
+ return true;
+ }
+ if (node instanceof AST_SwitchBranch) {
push();
descend();
pop();
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 6e079c1..405dbc2 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -2187,3 +2187,34 @@ issue_1814_2: {
}
expect_stdout: "0 '321'"
}
+
+try_abort: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ !function() {
+ try {
+ var a = 1;
+ throw "";
+ var b = 2;
+ } catch (e) {
+ }
+ console.log(a, b);
+ }();
+ }
+ expect: {
+ !function() {
+ try {
+ var a = 1;
+ throw "";
+ var b = 2;
+ } catch (e) {
+ }
+ console.log(a, b);
+ }();
+ }
+ expect_stdout: "1 undefined"
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list