parent
e4a91a89e0
commit
18f00457f6
|
|
@ -5927,6 +5927,16 @@ Compressor.prototype.compress = function(node) {
|
||||||
var references = Object.create(null);
|
var references = Object.create(null);
|
||||||
var prev = Object.create(null);
|
var prev = Object.create(null);
|
||||||
var tw = new TreeWalker(function(node, descend) {
|
var tw = new TreeWalker(function(node, descend) {
|
||||||
|
if (node.variables) {
|
||||||
|
if (node instanceof AST_BlockStatement) {
|
||||||
|
var save_scope = segment.scope;
|
||||||
|
segment.scope = node;
|
||||||
|
descend();
|
||||||
|
segment.scope = save_scope;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
segment.scope = node;
|
||||||
|
}
|
||||||
if (node instanceof AST_Assign) {
|
if (node instanceof AST_Assign) {
|
||||||
var lhs = node.left;
|
var lhs = node.left;
|
||||||
var rhs = node.right;
|
var rhs = node.right;
|
||||||
|
|
@ -6298,6 +6308,7 @@ Compressor.prototype.compress = function(node) {
|
||||||
var refs = references[def.id];
|
var refs = references[def.id];
|
||||||
if (!refs) return;
|
if (!refs) return;
|
||||||
if (refs.start.block !== seg.block) return references[def.id] = false;
|
if (refs.start.block !== seg.block) return references[def.id] = false;
|
||||||
|
sym.scope = seg.scope;
|
||||||
refs.push(sym);
|
refs.push(sym);
|
||||||
refs.end = seg;
|
refs.end = seg;
|
||||||
if (def.id in prev) {
|
if (def.id in prev) {
|
||||||
|
|
@ -6312,6 +6323,7 @@ Compressor.prototype.compress = function(node) {
|
||||||
return references[def.id] = false;
|
return references[def.id] = false;
|
||||||
} else {
|
} else {
|
||||||
var refs = declarations.get(def.id) || [];
|
var refs = declarations.get(def.id) || [];
|
||||||
|
sym.scope = seg.scope;
|
||||||
refs.push(sym);
|
refs.push(sym);
|
||||||
references[def.id] = refs;
|
references[def.id] = refs;
|
||||||
if (!read) {
|
if (!read) {
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ function OutputStream(options) {
|
||||||
|
|
||||||
function make_indent(value) {
|
function make_indent(value) {
|
||||||
if (typeof value == "number") return new Array(value + 1).join(" ");
|
if (typeof value == "number") return new Array(value + 1).join(" ");
|
||||||
|
if (!value) return "";
|
||||||
if (!/^\s*$/.test(value)) throw new Error("unsupported indentation: " + JSON.stringify("" + value));
|
if (!/^\s*$/.test(value)) throw new Error("unsupported indentation: " + JSON.stringify("" + value));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1813,3 +1813,33 @@ issue_5260: {
|
||||||
]
|
]
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5319: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
merge_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function(a, c) {
|
||||||
|
var b = a, c = b;
|
||||||
|
{
|
||||||
|
const a = c;
|
||||||
|
console.log(c());
|
||||||
|
}
|
||||||
|
})(function() {
|
||||||
|
return "PASS";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function(a, c) {
|
||||||
|
var b = a, c;
|
||||||
|
{
|
||||||
|
const a = c = b;
|
||||||
|
console.log(c());
|
||||||
|
}
|
||||||
|
})(function() {
|
||||||
|
return "PASS";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1973,3 +1973,36 @@ issue_5260: {
|
||||||
]
|
]
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_5319: {
|
||||||
|
options = {
|
||||||
|
collapse_vars: true,
|
||||||
|
merge_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
(function(a, c) {
|
||||||
|
var b = a, c = b;
|
||||||
|
{
|
||||||
|
let a = c;
|
||||||
|
console.log(c());
|
||||||
|
}
|
||||||
|
})(function() {
|
||||||
|
return "PASS";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
(function(a, c) {
|
||||||
|
var b = a, c;
|
||||||
|
{
|
||||||
|
let a = c = b;
|
||||||
|
console.log(c());
|
||||||
|
}
|
||||||
|
})(function() {
|
||||||
|
return "PASS";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user