correctly count declarations after hoist_vars (#2297)

fixes #2295
This commit is contained in:
Alex Lam S.L
2017-09-03 17:23:31 +08:00
committed by GitHub
parent 71d52f147d
commit 3f355866cf
2 changed files with 22 additions and 0 deletions

View File

@@ -3113,6 +3113,7 @@ merge(Compressor.prototype, {
}));
if (reduce_vars) name.definition().fixed = false;
}
remove(def.name.definition().orig, def.name);
return a;
}, []);
if (assignments.length == 0) return null;

View File

@@ -88,3 +88,24 @@ sequences_funs: {
}
}
}
issue_2295: {
options = {
collapse_vars: true,
hoist_vars: true,
}
input: {
function foo(o) {
var a = o.a;
if (a) return a;
var a = 1;
}
}
expect: {
function foo(o) {
var a = o.a;
if (a) return a;
a = 1;
}
}
}