@@ -3562,32 +3562,32 @@ merge(Compressor.prototype, {
|
|||||||
var regexp_props = makePredicate("global ignoreCase multiline source");
|
var regexp_props = makePredicate("global ignoreCase multiline source");
|
||||||
def(AST_PropAccess, function(compressor, ignore_side_effects, cached, depth) {
|
def(AST_PropAccess, function(compressor, ignore_side_effects, cached, depth) {
|
||||||
if (compressor.option("unsafe")) {
|
if (compressor.option("unsafe")) {
|
||||||
|
var val;
|
||||||
|
var exp = this.expression;
|
||||||
|
if (!is_undeclared_ref(exp)) {
|
||||||
|
val = exp._eval(compressor, ignore_side_effects, cached, depth + 1);
|
||||||
|
if (val == null || val === exp) return this;
|
||||||
|
}
|
||||||
var key = this.property;
|
var key = this.property;
|
||||||
if (key instanceof AST_Node) {
|
if (key instanceof AST_Node) {
|
||||||
key = key._eval(compressor, ignore_side_effects, cached, depth);
|
key = key._eval(compressor, ignore_side_effects, cached, depth);
|
||||||
if (key === this.property) return this;
|
if (key === this.property) return this;
|
||||||
}
|
}
|
||||||
var exp = this.expression;
|
if (val === undefined) {
|
||||||
var val;
|
|
||||||
if (is_undeclared_ref(exp)) {
|
|
||||||
var static_value = static_values[exp.name];
|
var static_value = static_values[exp.name];
|
||||||
if (!static_value || !static_value[key]) return this;
|
if (!static_value || !static_value[key]) return this;
|
||||||
val = global_objs[exp.name];
|
val = global_objs[exp.name];
|
||||||
} else {
|
} else if (val instanceof RegExp) {
|
||||||
val = exp._eval(compressor, ignore_side_effects, cached, depth + 1);
|
if (!regexp_props[key]) return this;
|
||||||
if (val == null || val === exp) return this;
|
} else if (typeof val == "object") {
|
||||||
if (val instanceof RegExp) {
|
if (!HOP(val, key)) return this;
|
||||||
if (!regexp_props[key]) return this;
|
} else if (typeof val == "function") switch (key) {
|
||||||
} else if (typeof val == "object") {
|
case "name":
|
||||||
if (!HOP(val, key)) return this;
|
return val.node.name ? val.node.name.name : "";
|
||||||
} else if (typeof val == "function") switch (key) {
|
case "length":
|
||||||
case "name":
|
return val.node.argnames.length;
|
||||||
return val.node.name ? val.node.name.name : "";
|
default:
|
||||||
case "length":
|
return this;
|
||||||
return val.node.argnames.length;
|
|
||||||
default:
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return val[key];
|
return val[key];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2735,3 +2735,27 @@ issue_3953: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3988: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unsafe: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(b) {
|
||||||
|
return ("" + (b &= 0))[b && this];
|
||||||
|
}
|
||||||
|
var a = f();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = function(b) {
|
||||||
|
return ("" + (b &= 0))[b && this];
|
||||||
|
}();
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "0"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user