simplify logic
add tests
This commit is contained in:
parent
8f97e6b176
commit
6c4f559920
|
|
@ -277,12 +277,6 @@ merge(Compressor.prototype, {
|
||||||
d.fixed = false;
|
d.fixed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node instanceof AST_Lambda) {
|
|
||||||
node.variables.get("arguments").fixed = null;
|
|
||||||
node.argnames.forEach(function(arg) {
|
|
||||||
arg.definition().fixed = null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (node instanceof AST_Defun) {
|
if (node instanceof AST_Defun) {
|
||||||
var d = node.name.definition();
|
var d = node.name.definition();
|
||||||
if (!toplevel && d.global || is_safe(d)) {
|
if (!toplevel && d.global || is_safe(d)) {
|
||||||
|
|
@ -364,7 +358,7 @@ merge(Compressor.prototype, {
|
||||||
function is_safe(def) {
|
function is_safe(def) {
|
||||||
for (var i = safe_ids.length, id = def.id; --i >= 0;) {
|
for (var i = safe_ids.length, id = def.id; --i >= 0;) {
|
||||||
if (safe_ids[i][id]) {
|
if (safe_ids[i][id]) {
|
||||||
if (def.fixed === null) {
|
if (def.fixed == null) {
|
||||||
var orig = def.orig[0];
|
var orig = def.orig[0];
|
||||||
if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
|
if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
|
||||||
def.fixed = make_node(AST_Undefined, orig);
|
def.fixed = make_node(AST_Undefined, orig);
|
||||||
|
|
|
||||||
|
|
@ -1823,3 +1823,34 @@ redefine_farg_3: {
|
||||||
}
|
}
|
||||||
expect_stdout: "object number undefined"
|
expect_stdout: "object number undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delay_def: {
|
||||||
|
options = {
|
||||||
|
evaluate: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
unused: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f() {
|
||||||
|
return a;
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
function g() {
|
||||||
|
return a;
|
||||||
|
var a = 1;
|
||||||
|
}
|
||||||
|
console.log(f(), g());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f() {
|
||||||
|
return a;
|
||||||
|
var a;
|
||||||
|
}
|
||||||
|
function g() {
|
||||||
|
return a;
|
||||||
|
var a = 1;
|
||||||
|
}
|
||||||
|
console.log(f(), g());
|
||||||
|
}
|
||||||
|
expect_stdout: true
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user