&& !fn.uses_arguments
&& !fn.pinned()) {
var pos = 0, last = 0;
+ var side_effects = [];
for (var i = 0; i < self.args.length; i++) {
var trim = i >= fn.argnames.length;
if (trim || fn.argnames[i].__unused) {
var node = self.args[i].drop_side_effect_free(compressor);
- if (node) {
- self.args[pos++] = node;
+ if (exp === fn) {
+ fn.argnames.splice(i, 1);
+ self.args.splice(i, 1);
+ if (node) side_effects.push(node);
+ i--;
+ continue;
+ } else if (node) {
+ side_effects.push(node);
+ self.args[pos++] = make_sequence(self, side_effects);
+ side_effects = [];
} else if (!trim) {
- self.args[pos++] = make_node(AST_Number, self.args[i], {
- value: 0
- });
+ if (side_effects.length) {
+ node = make_sequence(self, side_effects);
+ side_effects = [];
+ } else {
+ node = make_node(AST_Number, self.args[i], {
+ value: 0
+ });
+ }
+ self.args[pos++] = node;
continue;
}
} else {
- self.args[pos++] = self.args[i];
+ side_effects.push(self.args[i]);
+ self.args[pos++] = make_sequence(self, side_effects);
+ side_effects = [];
}
last = pos;
}
self.args.length = last;
+ if (side_effects.length) self.args.push(make_sequence(self, side_effects));
}
if (compressor.option("unsafe")) {
if (is_undeclared_ref(exp)) switch (exp.name) {
var a = 3, a = x;
return a;
}
- (function(x){
+ (function(x) {
var a = "GOOD" + x, e = "BAD", k = "!", e = a;
console.log(e + k);
})("!"),
- (function(x){
+ (function(x) {
var a = "GOOD" + x, e = "BAD" + x, k = "!", e = a;
console.log(e + k);
})("!");
function f2(x) {
return x;
}
- (function(x){
+ (function() {
console.log("GOOD!!");
})(),
- (function(x){
+ (function() {
console.log("GOOD!!");
})();
}
}(1));
}
expect: {
- console.log(function(x) {
+ console.log(function() {
var a = {}, b = a.b = 1;
return a.b + b;
}());
}(1, 2));
}
expect: {
- console.log(function(a, b) {
+ console.log(function(b) {
var c = 1;
c = b;
b++;
return c;
- }(0, 2));
+ }(2));
}
expect_stdout: "2"
}
}
expect: {
var b = 1;
- console.log(function(a) {
+ console.log(function() {
return b-- && ++b;
}());
}
console.log({
a: "FAIL",
b: function() {
- return function(c) {
+ return function() {
return (String, (Object, function() {
return this;
}())).a;
}()));
}
expect: {
- console.log(function(a) {
+ console.log(function() {
return !function() {
return this;
}();
}
expect: {
"use strict";
- console.log(function(a) {
+ console.log(function() {
return !function() {
return this;
}();
}
expect: {
var a = 8;
- (function(b, c) {
+ (function(b) {
b.toString();
})(--a, a |= 10);
console.log(a);
}
expect: {
var a = 8;
- (function(b, b) {
+ (function() {
(a |= 10).toString();
})(--a);
console.log(a);
var a = "PASS";
(function() {
(function(b) {
- (function(b) {
+ (function() {
a && (a.null = "FAIL");
})();
})();
expect: {
var c = 0;
function f0(bar) {
- (function(Infinity_2) {
- (function(NaN) {
+ (function() {
+ (function() {
if (false <= 0/0 & this >> 1 >= 0)
c++;
- })(0, c++);
+ })(c++);
})();
}
f0(false);
}
expect: {
var a = 100, b = 10;
- (function(c, o) {
+ (function(c) {
switch (~a) {
case (b += a):
- case o++:
+ case c++:
}
- })(--b, a);
+ })((--b, a));
console.log(a, b);
}
expect_stdout: "100 109"
}
expect: {
function m(t) {
- (function(e) {
+ (function() {
(function() {
- return (function(a) {
+ return (function() {
return function(a) {};
})();
})();
}(1, 2));
}
expect: {
- console.log(function(a, b) {
+ console.log(function(a) {
return a += 2;
}(1));
}
}(1, 2));
}
expect: {
- console.log(function(a, b) {
+ console.log(function(a) {
return a += 2;
}(1));
}
}(1, 2));
}
expect: {
- console.log(function(a, b) {
+ console.log(function(b) {
var c = b;
b++;
return c;
- }(0, 2));
+ }(2));
}
expect_stdout: "2"
}
}(0));
}
expect: {
- console.log(function(a) {
+ console.log(function() {
if (console)
return 1;
}());
}(0));
}
expect: {
- console.log(function(a) {
+ console.log(function() {
try {
return 1;
} catch (e) {}
expect: {
var x = 2, a = 1;
(function() {
- (function f1(a) {
+ (function f1() {
f2();
--x >= 0 && f1({});
})(a++);
function z() {
console.log("z");
}
- (function(a, b) {
+ (function(b) {
return function() {
console.log("FAIL");
} + b();
- })(x(), function() {
+ })((x(), function() {
return y();
- }, z());
+ }), z());
}
expect_stdout: [
"x",
}
expect: {
!function() {
- console.log(function(a) {
+ console.log(function() {
L: {
if (2) break L;
return 1;
function z() {
console.log("z");
}
- (function(a, b, c) {
+ (function(b) {
return function() {
console.log("FAIL");
} + b();
- })(x(), function() {
+ })((x(), function() {
return y();
- }, z());
+ }), z());
}
expect_stdout: [
"x",
})(2);
}
expect: {
- (function(a) {
+ (function() {
return g(3);
})();
}
});
}
expect: {
- !function(i) {
+ !function() {
if (Object())
return console.log("PASS");
throw "FAIL";