fix unused crash with top-level AST_Var (#2066)

fixes #2063
This commit is contained in:
Alex Lam S.L
2017-06-07 19:12:35 +08:00
committed by GitHub
parent 82fefc5d29
commit a7971f4e34
2 changed files with 17 additions and 1 deletions

View File

@@ -2278,7 +2278,9 @@ merge(Compressor.prototype, {
}
return node;
}
if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
if (node instanceof AST_Definitions
&& !(parent instanceof AST_ForIn && parent.init === node)
&& (drop_vars || !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var))) {
// place uninitialized names at the start
var body = [], head = [], tail = [];
// for unused names whose initialization has

View File

@@ -1280,3 +1280,17 @@ issue_1968: {
expect_stdout: "5"
node_version: ">=6"
}
issue_2063: {
options = {
unused: true,
}
input: {
var a;
var a;
}
expect: {
var a;
var a;
}
}