jashkenas/coffee-script — Issue #2097: 1.2.0: missing return generated
Author: lookfirst
Created: 2012-02-03 01:59:00+00:00
State: open

Apologies if this is a duplicate, this is the simplest syntax I could come up with:

```
_test: =>
for a in b
if c == d then return true
for e in f
if g then true
```

Notice the missing return statement in the last if statement:

```
XYZ.prototype._test = function() {
var a, e, _i, _j, _len, _len2;
for (_i = 0, _len = b.length; _i < _len; _i++) {
a = b[_i];
if (c === d) return true;
for (_j = 0, _len2 = f.length; _j < _len2; _j++) {
e = f[_j];
if (g) true;
}
}
};
```

Some odd variations do work (take the first return out):

```
_test: =>
for a in b
if c == d then true
for e in f
if g then true
```

Produces the expected result:

```
XYZ.prototype._test = function() {
var a, e, _i, _len, _results;
_results = [];
for (_i = 0, _len = b.length; _i < _len; _i++) {
a = b[_i];
if (c === d) true;
_results.push((function() {
var _j, _len2, _results2;
_results2 = [];
for (_j = 0, _len2 = f.length; _j < _len2; _j++) {
e = f[_j];
if (g) {
_results2.push(true);
} else {
_results2.push(void 0);
}
}
return _results2;
})());
}
return _results;
};
```