Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for binding shadowing outer var with loop closure (#15309)
* Fix for binding shadowing outer var with loop closure Fix updating of non-captured variable with loop closure * Rename
- Loading branch information
1 parent
64d5a92
commit fc66e99
Showing
17 changed files
with
158 additions
and
12 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
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
9 changes: 9 additions & 0 deletions
9
...nsform-block-scoping/test/fixtures/general/for-variable-update-different-captured/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,9 @@ | ||
let res = []; | ||
|
||
for (let i = 1; i < 6; i++) { | ||
let y = i; | ||
res.push((() => y)()); | ||
i++; | ||
} | ||
|
||
expect(res).toEqual([1, 3, 5]); |
5 changes: 5 additions & 0 deletions
5
...sform-block-scoping/test/fixtures/general/for-variable-update-different-captured/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,5 @@ | ||
for (let i = 4; i < 6; i++) { | ||
let y = i; | ||
() => y; | ||
i++; | ||
} |
11 changes: 11 additions & 0 deletions
11
...form-block-scoping/test/fixtures/general/for-variable-update-different-captured/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,11 @@ | ||
var _loop = function (_i) { | ||
var y = _i; | ||
(function () { | ||
return y; | ||
}); | ||
_i++; | ||
i = _i; | ||
}; | ||
for (var i = 4; i < 6; i++) { | ||
_loop(i); | ||
} |
8 changes: 8 additions & 0 deletions
8
...m-block-scoping/test/fixtures/general/issue-15308-for-variable-shadow-and-capture/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,8 @@ | ||
let res = []; | ||
|
||
let i = 0; | ||
for (let i = 4; i < 6; i++) { | ||
res.push((() => i)()); | ||
} | ||
|
||
expect(res).toEqual([4, 5]); |
4 changes: 4 additions & 0 deletions
4
...-block-scoping/test/fixtures/general/issue-15308-for-variable-shadow-and-capture/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 @@ | ||
let i; | ||
for (let i = 4; i < 6; i++) { | ||
() => i; | ||
} |
9 changes: 9 additions & 0 deletions
9
...block-scoping/test/fixtures/general/issue-15308-for-variable-shadow-and-capture/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,9 @@ | ||
var i; | ||
var _loop = function (i) { | ||
(function () { | ||
return i; | ||
}); | ||
}; | ||
for (var _i = 4; _i < 6; _i++) { | ||
_loop(_i); | ||
} |
10 changes: 10 additions & 0 deletions
10
...rm-block-scoping/test/fixtures/general/issue-15308-for-variable-shadow-and-update/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 @@ | ||
let res = []; | ||
|
||
let i = 0; | ||
for (let i = 1; i < 6; i++) { | ||
let y = i; | ||
res.push((() => y)()); | ||
i++; | ||
} | ||
|
||
expect(res).toEqual([1, 3, 5]); |
6 changes: 6 additions & 0 deletions
6
...m-block-scoping/test/fixtures/general/issue-15308-for-variable-shadow-and-update/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,6 @@ | ||
let i; | ||
for (let i = 4; i < 6; i++) { | ||
let y = i; | ||
() => y; | ||
i++; | ||
} |
12 changes: 12 additions & 0 deletions
12
...-block-scoping/test/fixtures/general/issue-15308-for-variable-shadow-and-update/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,12 @@ | ||
var i; | ||
var _loop = function (_i2) { | ||
var y = _i2; | ||
(function () { | ||
return y; | ||
}); | ||
_i2++; | ||
_i = _i2; | ||
}; | ||
for (var _i = 4; _i < 6; _i++) { | ||
_loop(_i); | ||
} |
13 changes: 13 additions & 0 deletions
13
...ping/test/fixtures/general/issue-15308-for-variable-shadow-original-sibling-scope/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,13 @@ | ||
let res = []; | ||
|
||
for (let i = 1; i < 3; i++) { | ||
let x = i; | ||
res.push((() => x)()); | ||
} | ||
|
||
for (let i = 4; i < 6; i++) { | ||
let y = i; | ||
res.push((() => y)()); | ||
} | ||
|
||
expect(res).toEqual([1, 2, 4, 5]); |
9 changes: 9 additions & 0 deletions
9
...ing/test/fixtures/general/issue-15308-for-variable-shadow-original-sibling-scope/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,9 @@ | ||
for (let i = 1; i < 3; i++) { | ||
let x = i; | ||
() => x; | ||
} | ||
|
||
for (let i = 4; i < 6; i++) { | ||
let y = i; | ||
() => y; | ||
} |
18 changes: 18 additions & 0 deletions
18
...ng/test/fixtures/general/issue-15308-for-variable-shadow-original-sibling-scope/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,18 @@ | ||
var _loop = function () { | ||
var x = i; | ||
(function () { | ||
return x; | ||
}); | ||
}; | ||
for (var i = 1; i < 3; i++) { | ||
_loop(); | ||
} | ||
var _loop2 = function () { | ||
var y = _i; | ||
(function () { | ||
return y; | ||
}); | ||
}; | ||
for (var _i = 4; _i < 6; _i++) { | ||
_loop2(); | ||
} |
9 changes: 9 additions & 0 deletions
9
...gin-transform-block-scoping/test/fixtures/general/issue-15308-for-variable-shadow/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,9 @@ | ||
let res = []; | ||
|
||
let i = 0; | ||
for (let i = 4; i < 6; i++) { | ||
let y = i; | ||
res.push((() => y)()); | ||
} | ||
|
||
expect(res).toEqual([4, 5]); |
5 changes: 5 additions & 0 deletions
5
...in-transform-block-scoping/test/fixtures/general/issue-15308-for-variable-shadow/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,5 @@ | ||
let i; | ||
for (let i = 4; i < 6; i++) { | ||
let y = i; | ||
() => y; | ||
} |
10 changes: 10 additions & 0 deletions
10
...n-transform-block-scoping/test/fixtures/general/issue-15308-for-variable-shadow/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,10 @@ | ||
var i; | ||
var _loop = function () { | ||
var y = _i; | ||
(function () { | ||
return y; | ||
}); | ||
}; | ||
for (var _i = 4; _i < 6; _i++) { | ||
_loop(); | ||
} |