bdkjones/CodeKit — Issue #75: Compiling fails on valid CoffeeScript
Author: doomspork
Created: 2011-11-11 19:26:13+00:00
State: open

I'm not entirely sure why this block of code is failing within CodeKit, but it is. The same error is generated even if the `switch` is swapped for a `if/else`. The use of `window.location.replace(response.data.location)` has no apparent impact. The Try CoffeeScript feature on the homepage is able to successfully compile this snippet.

### Code
```
switch response.status
when 'success'
window.location.replace response.data.location
when 'failure'
$.append('.errors') error for error in response.data.errors
```

### Error
Parse error on line 18: Unexpected 'LEADING_WHEN'

### Output from CoffeeScript's own web based parser
```
var error, _i, _len, _ref;

switch (response.status) {
case 'success':
window.location.replace(response.data.location);
break;
case 'failure':
_ref = response.data.errors;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
error = _ref[_i];
$.append('.errors')(error);
}
}
```