fix unused on var of the same name within catch (#1716)

fixes #1715
This commit is contained in:
Alex Lam S.L
2017-03-28 21:25:49 +08:00
committed by GitHub
parent f71f4905b0
commit c909ffb715
2 changed files with 94 additions and 1 deletions

View File

@@ -844,3 +844,90 @@ issue_1709: {
}
expect_stdout: true
}
issue_1715_1: {
options = {
unused: true,
}
input: {
var a = 1;
function f() {
a++;
try {} catch (a) {
var a;
}
}
f();
console.log(a);
}
expect: {
var a = 1;
function f() {
a++;
try {} catch (a) {
var a;
}
}
f();
console.log(a);
}
expect_stdout: "1"
}
issue_1715_2: {
options = {
unused: true,
}
input: {
var a = 1;
function f() {
a++;
try {} catch (a) {
var a = 2;
}
}
f();
console.log(a);
}
expect: {
var a = 1;
function f() {
a++;
try {} catch (a) {
var a;
}
}
f();
console.log(a);
}
expect_stdout: "1"
}
issue_1715_3: {
options = {
unused: true,
}
input: {
var a = 1;
function f() {
a++;
try {} catch (a) {
var a = 2 + x();
}
}
f();
console.log(a);
}
expect: {
var a = 1;
function f() {
a++;
try {} catch (a) {
var a = x();
}
}
f();
console.log(a);
}
expect_stdout: "1"
}