Fix shadow variables reassignment for block scoping in loops. (#6814)
This commit is contained in:
committed by
Mateusz Burzyński
parent
84fe8e4181
commit
056a995dd8
@@ -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));
|
||||
@@ -0,0 +1,7 @@
|
||||
for (let index = 0; index < 10; index++) {
|
||||
if (index % 2) {
|
||||
index+=3;
|
||||
continue;
|
||||
}
|
||||
let fn = function () {index;};
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user