[Pkg-javascript-commits] [uglifyjs] 73/228: fix a corner case in #1530 (#1552)
Jonas Smedegaard
dr at jones.dk
Sat Apr 15 14:25:18 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 78d1bb92d4560b73099afddd3bd2a85641bf3002
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Sun Mar 5 12:12:59 2017 +0800
fix a corner case in #1530 (#1552)
---
lib/compress.js | 10 ++++++----
test/compress/functions.js | 17 +++++++++++++++++
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index 3545900..7eead2c 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2760,10 +2760,12 @@ merge(Compressor.prototype, {
}
}
if (exp instanceof AST_Function) {
- if (exp.body[0] instanceof AST_Return
- && exp.body[0].value.is_constant()) {
- var args = self.args.concat(exp.body[0].value);
- return AST_Seq.from_array(args).transform(compressor);
+ if (exp.body[0] instanceof AST_Return) {
+ var value = exp.body[0].value;
+ if (!value || value.is_constant()) {
+ var args = self.args.concat(value || make_node(AST_Undefined, self));
+ return AST_Seq.from_array(args).transform(compressor);
+ }
}
if (compressor.option("side_effects")) {
if (!AST_Block.prototype.has_side_effects.call(exp, compressor)) {
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 18505a1..a1a515a 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -74,3 +74,20 @@ iifes_returning_constants_keep_fargs_false: {
console.log((a(), b(), 6));
}
}
+
+issue_485_crashing_1530: {
+ options = {
+ conditionals: true,
+ dead_code: true,
+ evaluate: true,
+ }
+ input: {
+ (function(a) {
+ if (true) return;
+ var b = 42;
+ })(this);
+ }
+ expect: {
+ this, void 0;
+ }
+}
--
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