-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle hoisted variables in dead branches of nested if statements (#3782
- Loading branch information
1 parent
f9b1026
commit 1a6cb46
Showing
8 changed files
with
337 additions
and
254 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ if (foo) { | |
} | ||
|
||
{ | ||
var bar = true; | ||
var bar; { | ||
bar = true; | ||
} | ||
} | ||
|
||
if (bar) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const assert = require('assert'); | ||
|
||
module.exports = { | ||
description: 'handles hoisted variables in chained if statements', | ||
exports(exports) { | ||
exports.test(true); | ||
assert.strictEqual(exports.result, 'first'); | ||
exports.test(false); | ||
assert.strictEqual(exports.result, 'third'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export let result; | ||
|
||
export function test(value) { | ||
if (value) { | ||
v = 'first'; | ||
result = v; | ||
} else if (false) { | ||
var v, w; | ||
result = 'second'; | ||
} else { | ||
v = 'third'; | ||
result = v; | ||
} | ||
|
||
for (var foo of []) if (false) var x; else { | ||
x = 'fourth'; | ||
result = x; | ||
} | ||
} |