[Pkg-javascript-commits] [uglifyjs] 02/50: fix `reduce_vars` within try-block (#1818)
Jonas Smedegaard
dr at jones.dk
Thu Aug 17 23:06:43 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository uglifyjs.
commit 6ad823d1e89fd27dfa423c261d29e9d3a60c6556
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 d1a5242..613c686 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -359,7 +359,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 7621dd4..ad7fcc6 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -2047,3 +2047,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