Skip to content

Commit

Permalink
Remove for-of variable qualifier requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohnson committed Oct 8, 2017
1 parent 0ec702c commit 2c8446a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 3 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,21 @@ The context-sensitive brace parser is implemented using speculative branching, w
### Rationale
Nobody was willing to strongly advocate for this feature or present a compelling use case. In general, the advantanges of `pipeCall`s are already available in the language through other means. Thus it's not worthwile maintaining this syntax.
## `for..of` loops no longer require `const`

### Change

```js
for x of xs: x
// lightscript 0.5.9
unknown: for-of requires a variable qualifier: `now` to reassign an existing variable, or `const`, `let`, `var` to declare a new one. (1:4)
> 1 | for x of xs: x
|
// @oigroup/lightscript 3.x
for (x of xs) { x }
```
### Rationale
Nobody was sure why this was being enforced; it is at odds with implicit qualification in other looping constructs like enhanced `for..in`.
2 changes: 2 additions & 0 deletions test/fixtures/for-in/shadowed/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
e = 1
for elem e in arr: e
4 changes: 4 additions & 0 deletions test/fixtures/for-in/shadowed/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const e = 1;
for (let _i = 0, _len = arr.length; _i < _len; _i++) {
const e = arr[_i];e;
}
1 change: 1 addition & 0 deletions test/fixtures/for-of/not-prefixed/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
for (x of generator) x;
3 changes: 0 additions & 3 deletions test/fixtures/for-of/not-prefixed/options.json

This file was deleted.

2 changes: 2 additions & 0 deletions test/fixtures/for-of/shadowed/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
e = 1
for e of arr: e
2 changes: 2 additions & 0 deletions test/fixtures/for-of/shadowed/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const e = 1;
for (e of arr) e;

0 comments on commit 2c8446a

Please sign in to comment.