mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 19:34:27 -05:00
empty returns no longer return null
This commit is contained in:
23
lib/nodes.js
23
lib/nodes.js
@@ -112,7 +112,7 @@
|
||||
BaseNode.prototype.eachChild = function(func) {
|
||||
var _i, _j, _len, _len2, _ref2, _ref3, _result, attr, child;
|
||||
if (!(this.children)) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
_result = []; _ref2 = this.children;
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
@@ -122,7 +122,7 @@
|
||||
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
|
||||
child = _ref3[_j];
|
||||
if (func(child) === false) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,18 +286,23 @@
|
||||
ReturnNode.prototype.children = ['expression'];
|
||||
ReturnNode.prototype.makeReturn = THIS;
|
||||
ReturnNode.prototype.compile = function(o) {
|
||||
var expr;
|
||||
expr = this.expression.makeReturn();
|
||||
if (!(expr instanceof ReturnNode)) {
|
||||
var _ref2, expr;
|
||||
expr = (((_ref2 = this.expression) != null) ? _ref2.makeReturn() : undefined);
|
||||
if (expr && (!(expr instanceof ReturnNode))) {
|
||||
return expr.compile(o);
|
||||
}
|
||||
return ReturnNode.__super__.compile.call(this, o);
|
||||
};
|
||||
ReturnNode.prototype.compileNode = function(o) {
|
||||
if (this.expression.isStatement(o)) {
|
||||
o.asStatement = true;
|
||||
var expr;
|
||||
expr = '';
|
||||
if (this.expression) {
|
||||
if (this.expression.isStatement(o)) {
|
||||
o.asStatement = true;
|
||||
}
|
||||
expr = ' ' + this.expression.compile(o);
|
||||
}
|
||||
return "" + (this.tab) + "return " + (this.expression.compile(o)) + ";";
|
||||
return "" + (this.tab) + "return" + expr + ";";
|
||||
};
|
||||
return ReturnNode;
|
||||
})();
|
||||
@@ -426,7 +431,7 @@
|
||||
ifnode = node.unfoldSoak(o);
|
||||
}
|
||||
if (!(ifnode)) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
parent[name] = ifnode.body;
|
||||
ifnode.body = new ValueNode(parent);
|
||||
|
||||
Reference in New Issue
Block a user