@@ -1599,9 +1599,13 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
if (node instanceof AST_SymbolRef) {
|
if (node instanceof AST_SymbolRef) {
|
||||||
if (symbol_in_lvalues(node, parent)) {
|
if (symbol_in_lvalues(node, parent)) {
|
||||||
return !parent || parent.operator != "=" || parent.left !== node;
|
return !(parent instanceof AST_Assign && parent.operator == "=" && parent.left === node);
|
||||||
}
|
}
|
||||||
return side_effects && may_modify(node);
|
if (side_effects && may_modify(node)) return true;
|
||||||
|
var def = node.definition();
|
||||||
|
return (in_try || def.scope.resolve() !== scope) && !all(def.orig, function(sym) {
|
||||||
|
return !(sym instanceof AST_SymbolConst);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (node instanceof AST_This) return symbol_in_lvalues(node, parent);
|
if (node instanceof AST_This) return symbol_in_lvalues(node, parent);
|
||||||
if (node instanceof AST_VarDef) {
|
if (node instanceof AST_VarDef) {
|
||||||
|
|||||||
@@ -776,3 +776,32 @@ issue_4195: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4197: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = 0;
|
||||||
|
try {
|
||||||
|
const b = function() {
|
||||||
|
a = 1;
|
||||||
|
b[1];
|
||||||
|
}();
|
||||||
|
} catch (e) {
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = 0;
|
||||||
|
try {
|
||||||
|
const b = function() {
|
||||||
|
a = 1;
|
||||||
|
b[1];
|
||||||
|
}();
|
||||||
|
} catch (e) {
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect_stdout: "1"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1348,7 +1348,7 @@ for (var round = 1; round <= num_iterations; round++) {
|
|||||||
ok = sandbox.same_stdout(sandbox.run_code(sort_globals(original_code)), sandbox.run_code(sort_globals(uglify_code)));
|
ok = sandbox.same_stdout(sandbox.run_code(sort_globals(original_code)), sandbox.run_code(sort_globals(uglify_code)));
|
||||||
}
|
}
|
||||||
// ignore numerical imprecision caused by `unsafe_math`
|
// ignore numerical imprecision caused by `unsafe_math`
|
||||||
if (!ok && typeof uglify_result == "string" && o.compress && o.compress.unsafe_math) {
|
if (!ok && o.compress && o.compress.unsafe_math && typeof original_result == "string" && typeof uglify_result == "string") {
|
||||||
ok = fuzzy_match(original_result, uglify_result);
|
ok = fuzzy_match(original_result, uglify_result);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
var fuzzy_result = sandbox.run_code(original_code.replace(/( - 0\.1){3}/g, " - 0.3"), toplevel);
|
var fuzzy_result = sandbox.run_code(original_code.replace(/( - 0\.1){3}/g, " - 0.3"), toplevel);
|
||||||
|
|||||||
Reference in New Issue
Block a user