jashkenas/coffee-script — pull request #2730 by mintplant (2013-02-27 05:05:26+00:00)
Title: Fix for #2715

This fixes the part of #2715 where

```coffeescript
test = (obj) -> obj.value
trans = (obj) -> obj

test trans
value: 'test'
```

ends up compiling to

```javascript
(function() {
var test, trans;

test = function(obj) {
return obj.value;
};

trans = function(obj) {
return obj;
};

test(trans)({
value: 'test'
});

}).call(this);
```

rather than

```javascript
(function() {
var test, trans;

test = function(obj) {
return obj.value;
};

trans = function(obj) {
return obj;
};

test(trans({
value: 'test'
}));

}).call(this);
```

At the same time,

```coffeescript
pass = ->
true

result = if pass 1
one: 1
eq result.one, 1
```

still compiles to

```javascript
(function() {
var pass, result;

pass = function() {
return true;
};

result = pass(1) ? {
one: 1
} : void 0;

eq(result.one, 1);

}).call(this);
```

The main heuristic used here is that the object in the second CoffeeScript snippet follows a statement (`if`, though `for`, `while`, etc. are also considered) where it is more likely to serve as a return value.