Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When hoisting a var, use UNKNOWN_EXPRESSION as the initializer instead of the actual one. This prevents the initializer from being used during the optimization step when it hasn't yet been assigned at runtime.
- Loading branch information
1 parent
b42e7fb
commit f8600a9
Showing
7 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
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,3 @@ | ||
module.exports = { | ||
description: 'Properly handles a variable hoisted from within a fallthrough switch case' | ||
}; |
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,8 @@ | ||
switch (someGlobal) { | ||
case 1: | ||
var hoisted = true; | ||
case 2: | ||
if (hoisted) { | ||
throw "failed"; | ||
} | ||
} |
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,8 @@ | ||
switch (someGlobal) { | ||
case 1: | ||
var hoisted = true; | ||
case 2: | ||
if (hoisted) { | ||
throw "failed"; | ||
} | ||
} |
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,4 @@ | ||
module.exports = { | ||
description: | ||
'Properly renders branches which refer to hoisted variables from other lexical scopes' | ||
}; |
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,15 @@ | ||
if (false) { | ||
var foo; | ||
} | ||
|
||
if (foo) { | ||
console.log("nope"); | ||
} | ||
|
||
{ | ||
var bar = true; | ||
} | ||
|
||
if (bar) { | ||
console.log("ok"); | ||
} |
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,15 @@ | ||
if (false) { | ||
var foo = true; | ||
} | ||
|
||
if (foo) { | ||
console.log("nope"); | ||
} | ||
|
||
if (true) { | ||
var bar = true; | ||
} | ||
|
||
if (bar) { | ||
console.log("ok"); | ||
} |