Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d17c5b0fa | ||
|
|
5b20bad4b3 | ||
|
|
765a06340f | ||
|
|
5045e140b1 | ||
|
|
10648c9af6 | ||
|
|
87e67ec299 |
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -14,6 +14,10 @@ jobs:
|
|||||||
TYPE: ${{ matrix.script }}
|
TYPE: ${{ matrix.script }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: tmp
|
||||||
|
key: tmp ${{ matrix.script }}
|
||||||
- shell: bash
|
- shell: bash
|
||||||
run: |
|
run: |
|
||||||
git clone --branch v1.5.2 --depth 1 https://github.com/jasongin/nvs.git ~/.nvs
|
git clone --branch v1.5.2 --depth 1 https://github.com/jasongin/nvs.git ~/.nvs
|
||||||
|
|||||||
@@ -1283,6 +1283,7 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
branch.expression = branch.expression.transform(scanner);
|
branch.expression = branch.expression.transform(scanner);
|
||||||
if (!replace_all) break;
|
if (!replace_all) break;
|
||||||
|
scan_rhs = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abort = true;
|
abort = true;
|
||||||
@@ -6542,23 +6543,30 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (self.left instanceof AST_SymbolRef) {
|
} else if (self.left instanceof AST_SymbolRef) {
|
||||||
|
if (self.left.is_immutable()) return strip_assignment();
|
||||||
var def = self.left.definition();
|
var def = self.left.definition();
|
||||||
if (def.scope === compressor.find_parent(AST_Lambda)) {
|
var scope = def.scope.resolve();
|
||||||
if (self.left.is_immutable()) return strip_assignment();
|
var local = scope === compressor.find_parent(AST_Lambda);
|
||||||
var level = 0, node, parent = self;
|
var level = 0, node, parent = self;
|
||||||
do {
|
do {
|
||||||
node = parent;
|
node = parent;
|
||||||
parent = compressor.parent(level++);
|
parent = compressor.parent(level++);
|
||||||
if (parent instanceof AST_Exit) {
|
if (parent instanceof AST_Assign) {
|
||||||
if (in_try(level, parent)) break;
|
if (!(parent.left instanceof AST_SymbolRef)) continue;
|
||||||
if (is_reachable(def.scope, [ def ])) break;
|
if (parent.left.definition() !== def) continue;
|
||||||
def.fixed = false;
|
if (in_try(level, parent)) break;
|
||||||
return strip_assignment();
|
def.fixed = false;
|
||||||
}
|
return strip_assignment();
|
||||||
} while (parent instanceof AST_Binary && parent.right === node
|
} else if (parent instanceof AST_Exit) {
|
||||||
|| parent instanceof AST_Sequence && parent.tail_node() === node
|
if (!local) break;
|
||||||
|| parent instanceof AST_UnaryPrefix);
|
if (in_try(level, parent)) break;
|
||||||
}
|
if (is_reachable(scope, [ def ])) break;
|
||||||
|
def.fixed = false;
|
||||||
|
return strip_assignment();
|
||||||
|
}
|
||||||
|
} while (parent instanceof AST_Binary && parent.right === node
|
||||||
|
|| parent instanceof AST_Sequence && parent.tail_node() === node
|
||||||
|
|| parent instanceof AST_UnaryPrefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self = self.lift_sequences(compressor);
|
self = self.lift_sequences(compressor);
|
||||||
@@ -6598,9 +6606,9 @@ merge(Compressor.prototype, {
|
|||||||
self.right = make_node(AST_Null, right);
|
self.right = make_node(AST_Null, right);
|
||||||
var may_throw = node.may_throw(compressor);
|
var may_throw = node.may_throw(compressor);
|
||||||
self.right = right;
|
self.right = right;
|
||||||
var scope = self.left.definition().scope;
|
|
||||||
var parent;
|
var parent;
|
||||||
while ((parent = compressor.parent(level++)) !== scope) {
|
while (parent = compressor.parent(level++)) {
|
||||||
|
if (parent === scope) return false;
|
||||||
if (parent instanceof AST_Try) {
|
if (parent instanceof AST_Try) {
|
||||||
if (parent.bfinally) return true;
|
if (parent.bfinally) return true;
|
||||||
if (may_throw && parent.bcatch) return true;
|
if (may_throw && parent.bcatch) return true;
|
||||||
@@ -6667,7 +6675,7 @@ merge(Compressor.prototype, {
|
|||||||
&& alt_tail instanceof AST_Assign
|
&& alt_tail instanceof AST_Assign
|
||||||
&& seq_tail.operator == alt_tail.operator
|
&& seq_tail.operator == alt_tail.operator
|
||||||
&& seq_tail.left.equivalent_to(alt_tail.left)
|
&& seq_tail.left.equivalent_to(alt_tail.left)
|
||||||
&& (is_eq && !seq_tail.left.has_side_effects(compressor)
|
&& (is_eq && seq_tail.left instanceof AST_SymbolRef
|
||||||
|| !condition.has_side_effects(compressor)
|
|| !condition.has_side_effects(compressor)
|
||||||
&& can_shift_lhs_of_tail(consequent)
|
&& can_shift_lhs_of_tail(consequent)
|
||||||
&& can_shift_lhs_of_tail(alternative))) {
|
&& can_shift_lhs_of_tail(alternative))) {
|
||||||
@@ -6836,16 +6844,9 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function can_shift_lhs_of_tail(node) {
|
function can_shift_lhs_of_tail(node) {
|
||||||
if (node === node.tail_node()) return true;
|
return node === node.tail_node() || all(node.expressions.slice(0, -1), function(expr) {
|
||||||
var exprs = node.expressions;
|
return !expr.has_side_effects(compressor);
|
||||||
for (var i = exprs.length - 1; --i >= 0;) {
|
});
|
||||||
var expr = exprs[i];
|
|
||||||
if (!(expr instanceof AST_Assign) && expr.has_side_effects(compressor)
|
|
||||||
|| expr.operator != "="
|
|
||||||
|| expr.left.has_side_effects(compressor)
|
|
||||||
|| expr.right.has_side_effects(compressor)) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pop_lhs(node) {
|
function pop_lhs(node) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"description": "JavaScript parser, mangler/compressor and beautifier toolkit",
|
"description": "JavaScript parser, mangler/compressor and beautifier toolkit",
|
||||||
"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.6.8",
|
"version": "3.6.9",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6435,3 +6435,36 @@ call_assign_order: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS PASS"
|
expect_stdout: "PASS PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3573: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var c = 0;
|
||||||
|
(function(b) {
|
||||||
|
while (--b) {
|
||||||
|
b = NaN;
|
||||||
|
switch (0 / this < 0) {
|
||||||
|
case c++, false:
|
||||||
|
case c++, NaN:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})(3);
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = 0;
|
||||||
|
(function(b) {
|
||||||
|
while (--b) {
|
||||||
|
b = NaN;
|
||||||
|
switch (0 / this < 0) {
|
||||||
|
case c++, false:
|
||||||
|
case c++, NaN:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})(3);
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "1"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1489,3 +1489,29 @@ angularjs_chain: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3576: {
|
||||||
|
options = {
|
||||||
|
conditionals: true,
|
||||||
|
evaluate: true,
|
||||||
|
pure_getters: "strict",
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var c = "FAIL";
|
||||||
|
(function(a) {
|
||||||
|
(a = -1) ? (a && (a.a = 0)) : (a && (a.a = 0));
|
||||||
|
a && a[c = "PASS"]++;
|
||||||
|
})();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var c = "FAIL";
|
||||||
|
(function(a) {
|
||||||
|
a = -1, a, a.a = 0;
|
||||||
|
a, a[c = "PASS"]++;
|
||||||
|
})();
|
||||||
|
console.log(c);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1064,3 +1064,68 @@ issue_3552: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unreachable_assign: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(A = "P" + (A = "A" + (B = "S" + (A = B = "S"))), A, B);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(A = "P" + "A" + (B = "S" + "S"), A, B);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS PASS SS"
|
||||||
|
}
|
||||||
|
|
||||||
|
catch_return_assign: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
try {
|
||||||
|
throw "FAIL";
|
||||||
|
} catch (e) {
|
||||||
|
return e = "PASS";
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
try {
|
||||||
|
throw "FAIL";
|
||||||
|
} catch (e) {
|
||||||
|
return "PASS";
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_3578: {
|
||||||
|
options = {
|
||||||
|
dead_code: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a = "FAIL", b, c;
|
||||||
|
try {
|
||||||
|
b = c.p = b = 0;
|
||||||
|
} catch (e) {
|
||||||
|
b += 42;
|
||||||
|
b && (a = "PASS");
|
||||||
|
}
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a = "FAIL", b, c;
|
||||||
|
try {
|
||||||
|
b = c.p = b = 0;
|
||||||
|
} catch (e) {
|
||||||
|
b += 42;
|
||||||
|
b && (a = "PASS");
|
||||||
|
}
|
||||||
|
console.log(a);
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user