Skip to content

Commit

Permalink
correctly count declarations after hoist_vars (#2297)
Browse files Browse the repository at this point in the history
fixes #2295
  • Loading branch information
alexlamsl committed Sep 3, 2017
1 parent 71d52f1 commit 3f35586
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions test/compress/hoist_vars.js
Expand Up @@ -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;
}
}
}

0 comments on commit 3f35586

Please sign in to comment.