jashkenas / jashkenas/coffeescript
Bug: Excess variable introduced in destructured `for ... from` loop
Open
- Dominant language
- CoffeeScript
- Stars
- 16.6k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
### Input Code
```coffee
for {x} from y
x
```
### Expected Behavior
```coffee
var x;
for ({x} of y) {
x;
}
```
### Current Behavior
```javascript
var x, z;
for (z of y) {
({x} = z);
x;
}
```
### Possible Solution
Extra variable `z` shouldn't be introduced.
* CoffeeScript version: 2.7.0
Contributor guide
Research direction
Reproduce the CoffeeScript 2.7.0 example `for {x} from y` and inspect the compiler path for destructured `for ... from` loops. Compare the generated JavaScript with the expected output; done means the loop no longer introduces `z` while preserving the destructuring behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- coffeescript, javascript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100