Skip to content

Commit 2cf8660

Browse files
committed
Add tests to improve coverage
1 parent c9ff97f commit 2cf8660

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

lib/ConstPlugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ const getHoistedDeclarations = (branch, includeFunctionDeclarations) => {
7878
break;
7979
case "TryStatement":
8080
stack.push(node.block);
81+
if(node.handler)
82+
stack.push(node.handler.body);
8183
stack.push(node.finalizer);
8284
break;
8385
case "FunctionDeclaration":

test/configCases/parsing/issue-4857/index.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,32 @@ it("should transpile unreachable branches", () => {
2828

2929
it("should not remove hoisted variable declarations", () => {
3030
if(false) {
31-
var a, [,,b,] = [], {c, D: d, ["E"]: e} = {};
31+
var a, [,,b,] = [], {c, D: d, ["E"]: e = 2} = {};
3232
var [{["_"]: f}, ...g] = [];
33+
do {
34+
switch(g) {
35+
default:
36+
var h;
37+
break;
38+
}
39+
loop: for(var i;;)
40+
for(var j in {})
41+
for(var k of {})
42+
break;
43+
try {
44+
var l;
45+
} catch(e) {
46+
var m;
47+
} finally {
48+
var n;
49+
}
50+
{
51+
var o;
52+
}
53+
} while(true);
54+
with (o) {
55+
var withVar;
56+
}
3357
}
3458
(() => {
3559
a;
@@ -39,7 +63,18 @@ it("should not remove hoisted variable declarations", () => {
3963
e;
4064
f;
4165
g;
66+
h;
67+
i;
68+
j;
69+
k;
70+
l;
71+
m;
72+
n;
73+
o;
4274
}).should.not.throw();
75+
(() => {
76+
withVar;
77+
}).should.throw();
4378
});
4479

4580
it("should not remove hoisted function declarations in loose mode", () => {

0 commit comments

Comments
 (0)