Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: hoist variable declaration within do block (#13122)
* fix: hoist variable declaration within do block * test: add input for variable-declaration-start * test: actually write a test for this issue * make prettier happy
- Loading branch information
Showing
11 changed files
with
64 additions
and
40 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...al-do-expressions/test/fixtures/do-expressions/variable-declaration-start-to-iife/exec.js
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,10 @@ | ||
expect( | ||
do { | ||
var bar = "foo"; | ||
if (!bar) throw new Error( | ||
"unreachable" | ||
) | ||
bar; | ||
} | ||
).toBe("foo"); | ||
expect(bar).toBe("foo"); |
7 changes: 7 additions & 0 deletions
7
...l-do-expressions/test/fixtures/do-expressions/variable-declaration-start-to-iife/input.js
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,7 @@ | ||
var x = do { | ||
var bar = "foo"; | ||
if (!bar) throw new Error( | ||
"unreachable" | ||
) | ||
bar; | ||
}; |
7 changes: 7 additions & 0 deletions
7
...-do-expressions/test/fixtures/do-expressions/variable-declaration-start-to-iife/output.js
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,7 @@ | ||
var bar; | ||
|
||
var x = function () { | ||
bar = "foo"; | ||
if (!bar) throw new Error("unreachable"); | ||
return bar; | ||
}(); |
7 changes: 7 additions & 0 deletions
7
...o-expressions/test/fixtures/do-expressions/variable-declaration-start-to-sequence/exec.js
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,7 @@ | ||
expect( | ||
do { | ||
var bar = "foo"; | ||
bar; | ||
} | ||
).toBe("foo"); | ||
expect(bar).toBe("foo"); |
4 changes: 4 additions & 0 deletions
4
...-expressions/test/fixtures/do-expressions/variable-declaration-start-to-sequence/input.js
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 @@ | ||
var x = do { | ||
var bar = "foo"; | ||
bar; | ||
}; |
2 changes: 2 additions & 0 deletions
2
...expressions/test/fixtures/do-expressions/variable-declaration-start-to-sequence/output.js
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,2 @@ | ||
var bar; | ||
var x = (bar = "foo", bar); |
4 changes: 0 additions & 4 deletions
4
...plugin-proposal-do-expressions/test/fixtures/do-expressions/variable-declaration-start.js
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
...posal-do-expressions/test/fixtures/do-expressions/variable-declaration-within-function.js
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 @@ | ||
expect( | ||
() => do { | ||
() => { | ||
var bar = "foo"; | ||
}; | ||
bar; | ||
} | ||
).toThrow(ReferenceError); |
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