jashkenas/coffee-script — Issue #2007: Parse error when returning object literals from array/object comprehensions
Author: rolftimmermans
Created: 2012-01-05 12:23:37+00:00
State: open

The following returns a compile error (Parse error on line 3: Unexpected 'TERMINATOR'):

```
y = for x in [1,2]
foo: "foo"
bar: "bar"
```

This works, however:

```
y = for x in [1,2]
null
foo: "foo"
bar: "bar"
```

And compiles to:

```
var x, y;

y = (function() {
var _i, _len, _ref, _results;
_ref = [1, 2];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
x = _ref[_i];
null;
_results.push({
foo: "foo",
bar: "bar"
});
}
return _results;
})();
```

I'd expect the first example to convert to the same code, except without the `null` statement in between.

Any idea what might be going on? I'd be happy to attempt to create a patch, but for now I'm not sure where to start.