@@ -2268,6 +2268,10 @@ merge(Compressor.prototype, {
|
|||||||
self.walk(new TreeWalker(function(node) {
|
self.walk(new TreeWalker(function(node) {
|
||||||
if (!result) return true;
|
if (!result) return true;
|
||||||
if (node instanceof AST_SymbolRef) {
|
if (node instanceof AST_SymbolRef) {
|
||||||
|
if (self.inlined) {
|
||||||
|
result = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
var def = node.definition();
|
var def = node.definition();
|
||||||
if (member(def, self.enclosed)
|
if (member(def, self.enclosed)
|
||||||
&& !self.variables.has(def.name)) {
|
&& !self.variables.has(def.name)) {
|
||||||
|
|||||||
@@ -554,3 +554,102 @@ issue_2428: {
|
|||||||
"PASS",
|
"PASS",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_2531_1: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function outer() {
|
||||||
|
function inner(value) {
|
||||||
|
function closure() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return function() {
|
||||||
|
return closure();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return inner("Hello");
|
||||||
|
}
|
||||||
|
console.log("Greeting:", outer()());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function outer() {
|
||||||
|
return function(value) {
|
||||||
|
return function() {
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
}("Hello");
|
||||||
|
}
|
||||||
|
console.log("Greeting:", outer()());
|
||||||
|
}
|
||||||
|
expect_stdout: "Greeting: Hello"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_2531_2: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function outer() {
|
||||||
|
function inner(value) {
|
||||||
|
function closure() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return function() {
|
||||||
|
return closure();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return inner("Hello");
|
||||||
|
}
|
||||||
|
console.log("Greeting:", outer()());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function outer() {
|
||||||
|
return function() {
|
||||||
|
return "Hello";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
console.log("Greeting:", outer()());
|
||||||
|
}
|
||||||
|
expect_stdout: "Greeting: Hello"
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_2531_3: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
inline: true,
|
||||||
|
passes: 2,
|
||||||
|
reduce_funcs: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function outer() {
|
||||||
|
function inner(value) {
|
||||||
|
function closure() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return function() {
|
||||||
|
return closure();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return inner("Hello");
|
||||||
|
}
|
||||||
|
console.log("Greeting:", outer()());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log("Greeting:", "Hello");
|
||||||
|
}
|
||||||
|
expect_stdout: "Greeting: Hello"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user