Skip to content

Commit 78d1bb9

Browse files
authoredMar 5, 2017
fix a corner case in #1530 (#1552)
1 parent ea9ab9f commit 78d1bb9

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed
 

‎lib/compress.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -2760,10 +2760,12 @@ merge(Compressor.prototype, {
27602760
}
27612761
}
27622762
if (exp instanceof AST_Function) {
2763-
if (exp.body[0] instanceof AST_Return
2764-
&& exp.body[0].value.is_constant()) {
2765-
var args = self.args.concat(exp.body[0].value);
2766-
return AST_Seq.from_array(args).transform(compressor);
2763+
if (exp.body[0] instanceof AST_Return) {
2764+
var value = exp.body[0].value;
2765+
if (!value || value.is_constant()) {
2766+
var args = self.args.concat(value || make_node(AST_Undefined, self));
2767+
return AST_Seq.from_array(args).transform(compressor);
2768+
}
27672769
}
27682770
if (compressor.option("side_effects")) {
27692771
if (!AST_Block.prototype.has_side_effects.call(exp, compressor)) {

‎test/compress/functions.js

+17
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,20 @@ iifes_returning_constants_keep_fargs_false: {
7474
console.log((a(), b(), 6));
7575
}
7676
}
77+
78+
issue_485_crashing_1530: {
79+
options = {
80+
conditionals: true,
81+
dead_code: true,
82+
evaluate: true,
83+
}
84+
input: {
85+
(function(a) {
86+
if (true) return;
87+
var b = 42;
88+
})(this);
89+
}
90+
expect: {
91+
this, void 0;
92+
}
93+
}

0 commit comments

Comments
 (0)
Please sign in to comment.