jashkenas/coffee-script — Issue #2154: Regression with bare object literal r-values
Author: sstephenson
Created: 2012-02-28 05:45:17+00:00
State: open

Sometime between CoffeeScript 1.1.3 and 1.2.0, the compilation for this block of code changed:

```coffeescript
getQuadrilateral = ->
@quadrilateral ?=
x1: @frontLeft.x
y1: @frontLeft.y
x2: @frontRight.x
y2: @frontRight.y
x3: @rearRight.x
y3: @rearRight.y
x4: @rearLeft.x
y4: @rearLeft.y
```

from this (1.1.3, expected):

```javascript
getQuadrilateral = function() {
var _ref;
return (_ref = this.quadrilateral) != null ? _ref : this.quadrilateral = {
x1: this.frontLeft.x,
y1: this.frontLeft.y,
x2: this.frontRight.x,
y2: this.frontRight.y,
x3: this.rearRight.x,
y3: this.rearRight.y,
x4: this.rearLeft.x,
y4: this.rearLeft.y
};
};
```

to this (1.2.0):

```javascript
getQuadrilateral = function() {
if (this.quadrilateral == null) {
this.quadrilateral = {
x1: this.frontLeft.x
};
}
return {
y1: this.frontLeft.y,
x2: this.frontRight.x,
y2: this.frontRight.y,
x3: this.rearRight.x,
y3: this.rearRight.y,
x4: this.rearLeft.x,
y4: this.rearLeft.y
};
};
```