Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e00a12741 | ||
|
|
10b3752b1e | ||
|
|
fe51a91395 |
@@ -778,8 +778,7 @@ merge(Compressor.prototype, {
|
|||||||
lhs = lhs.fixed_value();
|
lhs = lhs.fixed_value();
|
||||||
}
|
}
|
||||||
if (!lhs) return true;
|
if (!lhs) return true;
|
||||||
if (lhs instanceof AST_RegExp) return false;
|
if (lhs.is_constant()) return true;
|
||||||
if (lhs instanceof AST_Constant) return true;
|
|
||||||
return is_lhs_read_only(lhs);
|
return is_lhs_read_only(lhs);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
12
lib/scope.js
12
lib/scope.js
@@ -74,17 +74,12 @@ SymbolDef.prototype = {
|
|||||||
var cache = options.cache && options.cache.props;
|
var cache = options.cache && options.cache.props;
|
||||||
if (this.global && cache && cache.has(this.name)) {
|
if (this.global && cache && cache.has(this.name)) {
|
||||||
this.mangled_name = cache.get(this.name);
|
this.mangled_name = cache.get(this.name);
|
||||||
}
|
} else if (!this.mangled_name && !this.unmangleable(options)) {
|
||||||
else if (!this.mangled_name && !this.unmangleable(options)) {
|
|
||||||
var s = this.scope;
|
|
||||||
var sym = this.orig[0];
|
|
||||||
if (options.ie8 && sym instanceof AST_SymbolLambda)
|
|
||||||
s = s.parent_scope;
|
|
||||||
var def;
|
var def;
|
||||||
if (def = this.redefined()) {
|
if (def = this.redefined()) {
|
||||||
this.mangled_name = def.mangled_name || def.name;
|
this.mangled_name = def.mangled_name || def.name;
|
||||||
} else {
|
} else {
|
||||||
this.mangled_name = next_mangled_name(s, options, this);
|
this.mangled_name = next_mangled_name(this.scope, options, this);
|
||||||
}
|
}
|
||||||
if (this.global && cache) {
|
if (this.global && cache) {
|
||||||
cache.set(this.name, this.mangled_name);
|
cache.set(this.name, this.mangled_name);
|
||||||
@@ -377,6 +372,9 @@ function next_mangled_name(scope, options, def) {
|
|||||||
holes.push(scope.cname);
|
holes.push(scope.cname);
|
||||||
}
|
}
|
||||||
scope.names_in_use[name] = true;
|
scope.names_in_use[name] = true;
|
||||||
|
if (options.ie8 && def.orig[0] instanceof AST_SymbolLambda) {
|
||||||
|
names_in_use(scope.parent_scope, options)[name] = true;
|
||||||
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"homepage": "http://lisperator.net/uglifyjs",
|
"homepage": "http://lisperator.net/uglifyjs",
|
||||||
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"version": "3.3.13",
|
"version": "3.3.14",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5207,3 +5207,39 @@ collapse_rhs_undefined: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "true true true"
|
expect_stdout: "true true true"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2974: {
|
||||||
|
options = {
|
||||||
|
booleans: true,
|
||||||
|
collapse_vars: true,
|
||||||
|
evaluate: true,
|
||||||
|
loops: true,
|
||||||
|
passes: 2,
|
||||||
|
pure_getters: "strict",
|
||||||
|
reduce_vars: true,
|
||||||
|
sequences: true,
|
||||||
|
side_effects: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var c = 0;
|
||||||
|
(function f(b) {
|
||||||
|
var a = 2;
|
||||||
|
do {
|
||||||
|
b && b[b];
|
||||||
|
b && (b.null = -4);
|
||||||
|
c++;
|
||||||
|
} while (b.null && --a > 0);
|
||||||
|
})(true);
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = 0;
|
||||||
|
(function(b) {
|
||||||
|
var a = 2;
|
||||||
|
for (; b.null = -4, c++, b.null && --a > 0;);
|
||||||
|
})(!0),
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "1"
|
||||||
|
}
|
||||||
|
|||||||
@@ -392,3 +392,75 @@ issue_2254_2: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_24_1: {
|
||||||
|
mangle = {
|
||||||
|
ie8: false,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a) {
|
||||||
|
console.log(typeof function f(){} === typeof a ? "FAIL" : "PASS");
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(o) {
|
||||||
|
console.log(typeof function o(){} === typeof o ? "FAIL" : "PASS");
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_24_2: {
|
||||||
|
mangle = {
|
||||||
|
ie8: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a) {
|
||||||
|
console.log(typeof function f(){} === typeof a ? "FAIL" : "PASS");
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(n) {
|
||||||
|
console.log(typeof function o(){} === typeof n ? "FAIL" : "PASS");
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_2976_1: {
|
||||||
|
mangle = {
|
||||||
|
ie8: false,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function f() {
|
||||||
|
var a;
|
||||||
|
return a === f ? "FAIL" : "PASS";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function n() {
|
||||||
|
var o;
|
||||||
|
return o === n ? "FAIL" : "PASS";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_2976_2: {
|
||||||
|
mangle = {
|
||||||
|
ie8: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function f() {
|
||||||
|
var a;
|
||||||
|
return a === f ? "FAIL" : "PASS";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function n() {
|
||||||
|
var o;
|
||||||
|
return o === n ? "FAIL" : "PASS";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user