mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fix for #926
This commit is contained in:
parent
941f5a8ecb
commit
346621ed21
3 changed files with 7 additions and 14 deletions
|
@ -458,7 +458,6 @@
|
|||
case '\\':
|
||||
i++;
|
||||
continue;
|
||||
break;
|
||||
case stack[stack.length - 1][1]:
|
||||
stack.pop();
|
||||
if (!stack.length) {
|
||||
|
|
14
lib/nodes.js
14
lib/nodes.js
|
@ -1915,7 +1915,7 @@
|
|||
return this;
|
||||
};
|
||||
Switch.prototype.compileNode = function(o) {
|
||||
var block, body, code, cond, conditions, expr, i, idt1, idt2, _i, _j, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4, _ref5;
|
||||
var block, body, code, cond, conditions, exprs, i, idt1, idt2, _i, _len, _len2, _ref, _ref2, _ref3, _ref4;
|
||||
idt1 = o.indent + TAB;
|
||||
idt2 = o.indent = idt1 + TAB;
|
||||
code = this.tab + ("switch (" + (((_ref = this.subject) != null ? _ref.compile(o, LEVEL_PAREN) : void 0) || false) + ") {\n");
|
||||
|
@ -1936,15 +1936,9 @@
|
|||
if (i === this.cases.length - 1 && !this.otherwise) {
|
||||
break;
|
||||
}
|
||||
_ref5 = block.expressions;
|
||||
for (_j = 0, _len3 = _ref5.length; _j < _len3; _j += -1) {
|
||||
expr = _ref5[_j];
|
||||
if (!(expr instanceof Comment)) {
|
||||
if (!(expr instanceof Return)) {
|
||||
code += idt2 + 'break;\n';
|
||||
}
|
||||
break;
|
||||
}
|
||||
exprs = block.expressions;
|
||||
if (!exprs.length || !last(exprs).isPureStatement()) {
|
||||
code += idt2 + 'break;\n';
|
||||
}
|
||||
}
|
||||
if (this.otherwise) {
|
||||
|
|
|
@ -1524,9 +1524,9 @@ exports.Switch = class Switch extends Base
|
|||
code += idt1 + "case #{ cond.compile o, LEVEL_PAREN }:\n"
|
||||
code += body + '\n' if body = block.compile o, LEVEL_TOP
|
||||
break if i is @cases.length - 1 and not @otherwise
|
||||
for expr in block.expressions by -1 when expr not instanceof Comment
|
||||
code += idt2 + 'break;\n' unless expr instanceof Return
|
||||
break
|
||||
exprs = block.expressions
|
||||
if not exprs.length or not last(exprs).isPureStatement()
|
||||
code += idt2 + 'break;\n'
|
||||
code += idt1 + "default:\n#{ @otherwise.compile o, LEVEL_TOP }\n" if @otherwise
|
||||
code + @tab + '}'
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue