jashkenas / jashkenas/coffeescript
Bug: Implicit object literals in array split improperly
- Dominant language
- CoffeeScript
- Stars
- 16.6k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
[#try](http://coffeescript.org/#try:a%20%3D%20%5B%0A%20%20b1%3A%201%0A%20%20b2%3A%202%0A%2C%20c1%3A%201%0A%20%20c2%3A%202%0A%5D%0A)
### Input Code
```coffee
a = [
b1: 1
b2: 2
, c1: 1
c2: 2
]
```
### Expected Behavior
```js
var a;
a = [
{
b1: 1,
b2: 2
},
{
c1: 1,
c2: 2
}
];
```
### Current Behavior
```js
var a;
a = [
{
b1: 1,
b2: 2
},
{
c1: 1
},
{
c2: 2
}
];
```
### Context
Fixing this should provide a reasonable alternative to #4952.
Side note: I ran into this issue writing the initial AST tests but never got around to [file it](https://github.com/GeoffreyBooth/coffeescript/blob/90d15176cb5b839b93f2989ec8fd63868d521458/test/abstract_syntax_tree.coffee#L426) (until now).
I felt like having read about this syntax/semantics in an official source like coffeescript.org but was unable to find the reference again.
### Environment
* CoffeeScript version: v2.5.1
Contributor guide
Research direction
Reproduce the array example from the issue and inspect test/abstract_syntax_tree.coffee around line 426, where related AST tests are referenced. Trace how implicit object literals in arrays are split, then add coverage showing two object elements and verify the generated JavaScript matches the expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- coffeescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100