-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix shadow variables reassignment for block scoping in loops. (#6814)
- Loading branch information
Showing
4 changed files
with
48 additions
and
0 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
13 changes: 13 additions & 0 deletions
13
...bel-plugin-transform-block-scoping/test/fixtures/exec/for-continuation-outer-reference.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 @@ | ||
let data = [true, false, false, true, false]; | ||
|
||
for (let index = 0; index < data.length; index++) { | ||
let item = data[index]; | ||
if (!item) { | ||
data.splice(index, 1); | ||
index--; | ||
continue; | ||
} | ||
let fn = function () {item;}; | ||
} | ||
|
||
assert(data.every(item => item)); |
7 changes: 7 additions & 0 deletions
7
...-block-scoping/test/fixtures/general/wrap-closure-shadow-variables-reassignment/actual.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 @@ | ||
for (let index = 0; index < 10; index++) { | ||
if (index % 2) { | ||
index+=3; | ||
continue; | ||
} | ||
let fn = function () {index;}; | ||
} |
19 changes: 19 additions & 0 deletions
19
...lock-scoping/test/fixtures/general/wrap-closure-shadow-variables-reassignment/expected.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,19 @@ | ||
var _loop = function (_index) { | ||
if (_index % 2) { | ||
_index += 3; | ||
index = _index; | ||
return "continue"; | ||
} | ||
|
||
var fn = function () { | ||
_index; | ||
}; | ||
|
||
index = _index; | ||
}; | ||
|
||
for (var index = 0; index < 10; index++) { | ||
var _ret = _loop(index); | ||
|
||
if (_ret === "continue") continue; | ||
} |