Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: check constant violation inside loops
Co-authored-by: Nicol貌 Ribaudo <nicolo.ribaudo@gmail.com>
- Loading branch information
1 parent
4fb29a3
commit b33b4c9
Showing
7 changed files
with
48 additions
and
6 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
11 changes: 11 additions & 0 deletions
11
...gin-transform-block-scoping/test/fixtures/const-violations/assignment-in-for-loop/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,11 @@ | ||
expect(function () { | ||
for (const element = 1; element++;) break; | ||
}).toThrow('"element" is read-only'); | ||
|
||
expect(function () { | ||
for (;;) { | ||
const from = 50; | ||
from--; | ||
break; | ||
} | ||
}).toThrow('"from" is read-only'); |
4 changes: 4 additions & 0 deletions
4
...in-transform-block-scoping/test/fixtures/const-violations/assignment-in-for-loop/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 @@ | ||
for (const element = 1; element++;) { | ||
const from = 50; | ||
from--; | ||
} |
4 changes: 4 additions & 0 deletions
4
...n-transform-block-scoping/test/fixtures/const-violations/assignment-in-for-loop/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,4 @@ | ||
for (var element = 1; +element, babelHelpers.readOnlyError("element");) { | ||
var from = 50; | ||
+from, babelHelpers.readOnlyError("from"); | ||
} |
7 changes: 7 additions & 0 deletions
7
...-transform-block-scoping/test/fixtures/const-violations/assignment-in-for-of-loop/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(function () { | ||
const array = [1, 2, 3]; | ||
for (const element of array) { | ||
const from = 50; | ||
from--; | ||
} | ||
}).toThrow('"from" is read-only'); |
4 changes: 4 additions & 0 deletions
4
...transform-block-scoping/test/fixtures/const-violations/assignment-in-for-of-loop/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 @@ | ||
for (const element of []) { | ||
const from = 50; | ||
from--; | ||
} |
4 changes: 4 additions & 0 deletions
4
...ransform-block-scoping/test/fixtures/const-violations/assignment-in-for-of-loop/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,4 @@ | ||
for (var element of []) { | ||
var from = 50; | ||
+from, babelHelpers.readOnlyError("from"); | ||
} |