1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

fixing explicit returns of comprehensions (and probably other things as well)

This commit is contained in:
Jeremy Ashkenas 2010-03-25 18:51:24 -04:00
parent ad93d2fe4d
commit ecd1c77f48
3 changed files with 21 additions and 3 deletions

View file

@ -434,7 +434,8 @@
} else if (_a === ')') {
tok[0] = 'PARAM_END';
} else if (_a === '(') {
return (tok[0] = 'PARAM_START');
tok[0] = 'PARAM_START';
return tok[0];
}
}
return true;
@ -548,7 +549,8 @@
return null;
}
if ((typeof tag !== "undefined" && tag !== null)) {
return (tok[0] = tag);
tok[0] = tag;
return tok[0];
}
return tok[0];
};
@ -559,7 +561,8 @@
return null;
}
if ((typeof val !== "undefined" && val !== null)) {
return (tok[1] = val);
tok[1] = val;
return tok[1];
}
return tok[1];
};

View file

@ -346,7 +346,16 @@
};
__extends(ReturnNode, BaseNode);
ReturnNode.prototype.type = 'Return';
ReturnNode.prototype.top_sensitive = function top_sensitive() {
return true;
};
ReturnNode.prototype.compile_node = function compile_node(o) {
var expr;
expr = this.expression.make_return();
if (!(expr instanceof ReturnNode)) {
return expr.compile(o);
}
del(o, 'top');
if (this.expression.is_statement()) {
o.as_statement = true;
}

View file

@ -243,7 +243,13 @@ exports.ReturnNode: class ReturnNode extends BaseNode
constructor: (expression) ->
@children: [@expression: expression]
top_sensitive: ->
true
compile_node: (o) ->
expr: @expression.make_return()
return expr.compile(o) unless expr instanceof ReturnNode
del o, 'top'
o.as_statement: true if @expression.is_statement()
"${@tab}return ${@expression.compile(o)};"