@@ -485,9 +485,10 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function safe_to_assign(tw, def, declare) {
|
function safe_to_assign(tw, def, declare) {
|
||||||
if (def.fixed === undefined) return declare || all(def.orig, function(sym) {
|
if (!(declare || all(def.orig, function(sym) {
|
||||||
return !(sym instanceof AST_SymbolConst);
|
return !(sym instanceof AST_SymbolConst);
|
||||||
});
|
}))) return false;
|
||||||
|
if (def.fixed === undefined) return true;
|
||||||
if (def.fixed === null && def.safe_ids) {
|
if (def.fixed === null && def.safe_ids) {
|
||||||
def.safe_ids[def.id] = false;
|
def.safe_ids[def.id] = false;
|
||||||
delete def.safe_ids;
|
delete def.safe_ids;
|
||||||
@@ -8557,7 +8558,9 @@ merge(Compressor.prototype, {
|
|||||||
]).optimize(compressor);
|
]).optimize(compressor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (self.left instanceof AST_SymbolRef) {
|
} else if (self.left instanceof AST_SymbolRef && all(self.left.definition().orig, function(sym) {
|
||||||
|
return !(sym instanceof AST_SymbolConst);
|
||||||
|
})) {
|
||||||
var parent;
|
var parent;
|
||||||
if (self.operator == "=" && self.left.equivalent_to(self.right)
|
if (self.operator == "=" && self.left.equivalent_to(self.right)
|
||||||
&& !((parent = compressor.parent()) instanceof AST_UnaryPrefix && parent.operator == "delete")) {
|
&& !((parent = compressor.parent()) instanceof AST_UnaryPrefix && parent.operator == "delete")) {
|
||||||
|
|||||||
@@ -963,3 +963,49 @@ issue_4210: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4212_1: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log({
|
||||||
|
get b() {
|
||||||
|
const a = 0;
|
||||||
|
return a /= 0;
|
||||||
|
}
|
||||||
|
}.b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log({
|
||||||
|
get b() {
|
||||||
|
const a = 0;
|
||||||
|
return a /= 0;
|
||||||
|
}
|
||||||
|
}.b);
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4212_2: {
|
||||||
|
options = {
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log({
|
||||||
|
get b() {
|
||||||
|
const a = 0;
|
||||||
|
return a /= 0;
|
||||||
|
}
|
||||||
|
}.b);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log({
|
||||||
|
get b() {
|
||||||
|
const a = 0;
|
||||||
|
return a /= 0;
|
||||||
|
}
|
||||||
|
}.b);
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|||||||
@@ -899,12 +899,14 @@ function getDotKey(assign) {
|
|||||||
function createAccessor(recurmax, stmtDepth, canThrow) {
|
function createAccessor(recurmax, stmtDepth, canThrow) {
|
||||||
var namesLenBefore = VAR_NAMES.length;
|
var namesLenBefore = VAR_NAMES.length;
|
||||||
var s;
|
var s;
|
||||||
|
createBlockVariables(recurmax, stmtDepth, canThrow, function(defns) {
|
||||||
var prop1 = getDotKey();
|
var prop1 = getDotKey();
|
||||||
if (rng(2) == 0) {
|
if (rng(2) == 0) {
|
||||||
s = [
|
s = [
|
||||||
"get " + prop1 + "(){",
|
"get " + prop1 + "(){",
|
||||||
strictMode(),
|
strictMode(),
|
||||||
createStatements(2, recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth),
|
defns(),
|
||||||
|
_createStatements(2, recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth),
|
||||||
createStatement(recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth, STMT_RETURN_ETC),
|
createStatement(recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth, STMT_RETURN_ETC),
|
||||||
"},"
|
"},"
|
||||||
];
|
];
|
||||||
@@ -913,7 +915,6 @@ function createAccessor(recurmax, stmtDepth, canThrow) {
|
|||||||
do {
|
do {
|
||||||
prop2 = getDotKey();
|
prop2 = getDotKey();
|
||||||
} while (prop1 == prop2);
|
} while (prop1 == prop2);
|
||||||
createBlockVariables(recurmax, stmtDepth, canThrow, function(defns) {
|
|
||||||
s = [
|
s = [
|
||||||
"set " + prop1 + "(" + createVarName(MANDATORY) + "){",
|
"set " + prop1 + "(" + createVarName(MANDATORY) + "){",
|
||||||
strictMode(),
|
strictMode(),
|
||||||
@@ -922,8 +923,8 @@ function createAccessor(recurmax, stmtDepth, canThrow) {
|
|||||||
"this." + prop2 + createAssignment() + _createBinaryExpr(recurmax, COMMA_OK, stmtDepth, canThrow) + ";",
|
"this." + prop2 + createAssignment() + _createBinaryExpr(recurmax, COMMA_OK, stmtDepth, canThrow) + ";",
|
||||||
"},"
|
"},"
|
||||||
];
|
];
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
VAR_NAMES.length = namesLenBefore;
|
VAR_NAMES.length = namesLenBefore;
|
||||||
return filterDirective(s).join("\n");
|
return filterDirective(s).join("\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user