Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix break/continue when switch is nested inside loop (#11802)
* Fix break/continue when switch is nested inside loop * merge retCheck
- Loading branch information
1 parent
b1a8e72
commit 58cfaf2
Showing
6 changed files
with
72 additions
and
60 deletions.
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
15 changes: 15 additions & 0 deletions
15
...l-plugin-transform-block-scoping/test/fixtures/general/for-break-continue-closure/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,15 @@ | ||
expect(() => { | ||
for (const a of [1]) { | ||
switch (true) { | ||
case true: { | ||
const b = 1; | ||
() => b; | ||
if (true) break; | ||
continue; | ||
} | ||
case false: { | ||
throw new Error("unreachable"); | ||
} | ||
} | ||
} | ||
}).not.toThrow(); |
13 changes: 13 additions & 0 deletions
13
...-plugin-transform-block-scoping/test/fixtures/general/for-break-continue-closure/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,13 @@ | ||
for (const a of [1]) { | ||
switch (true) { | ||
case true: { | ||
const b = 1; | ||
() => b; | ||
if (true) break; | ||
continue; | ||
} | ||
case false: { | ||
throw new Error("unreachable"); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...plugin-transform-block-scoping/test/fixtures/general/for-break-continue-closure/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,25 @@ | ||
for (var a of [1]) { | ||
switch (true) { | ||
case true: | ||
{ | ||
var _ret = function () { | ||
var b = 1; | ||
|
||
(function () { | ||
return b; | ||
}); | ||
|
||
if (true) return "break"; | ||
return "continue"; | ||
}(); | ||
|
||
if (_ret === "break") break; | ||
if (_ret === "continue") continue; | ||
} | ||
|
||
case false: | ||
{ | ||
throw new Error("unreachable"); | ||
} | ||
} | ||
} |
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