Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed the naked autocb problem

  • Loading branch information...
commit 1520ef1076eff10f35fac49152e556f41b206d87 1 parent bb113f9
@maxtaco authored
View
8 lib/coffee-script/nodes.js
@@ -687,10 +687,10 @@
Return.prototype.isStatement = YES;
- Return.prototype.makeReturn = THIS;
-
Return.prototype.jumps = THIS;
+ Return.prototype.makeReturn = THIS;
+
Return.prototype.compile = function(o, level) {
var expr, _ref2;
expr = (_ref2 = this.expression) != null ? _ref2.makeReturn() : void 0;
@@ -1788,6 +1788,10 @@
o.scope.parameter(vars[i] = v.compile(o));
}
}
+ if (wasEmpty && this.tameHasAutocbFlag) {
+ this.body.expressions.unshift(new Return(null, true));
+ wasEmpty = false;
+ }
if (!(wasEmpty || this.noReturn)) this.body.makeReturn();
if (this.bound) {
if ((_ref6 = o.scope.parent.method) != null ? _ref6.bound : void 0) {
View
3  lib/coffee-script/tamelib.js
@@ -57,9 +57,10 @@
}
Pipeliner.prototype.waitInQueue = function(cb) {
- var __tame_deferrals, _while,
+ var __tame_deferrals,
_this = this;
(function(__tame_k) {
+ var _while;
_while = function(__tame_k) {
var _break, _continue;
_break = __tame_k;
View
10 src/nodes.coffee
@@ -1456,6 +1456,12 @@ exports.Code = class Code extends Base
for name in @paramNames()
throw SyntaxError "multiple parameters named '#{name}'" if name in uniqs
uniqs.push name
+
+ # Empty guys should still autocb
+ if wasEmpty and @tameHasAutocbFlag
+ @body.expressions.unshift(new Return null, true)
+ wasEmpty = false
+
@body.makeReturn() unless wasEmpty or @noReturn
if @bound
if o.scope.parent.method?.bound
@@ -1465,12 +1471,9 @@ exports.Code = class Code extends Base
idt = o.indent
code = 'function'
code += ' ' + @name if @ctor
-<<<<<<< HEAD
code += '(' + params.join(', ') + ') {'
if @tameNodeFlag
o.tamed_scope = o.scope
-=======
- code += '(' + vars.join(', ') + ') {'
# There are two important cases to consider in terms of autocb;
# In the case of an explicit call to return, we handle it in
@@ -1486,7 +1489,6 @@ exports.Code = class Code extends Base
k_id = new Value new Literal tame.const.k
@body.unshift(new Assign k_id, rhs, null, { param : yes })
->>>>>>> betteR! gotta run, but close!
code += "\n#{ @body.compileWithDeclarations o }\n#{@tab}" unless @body.isEmpty()
code += '}'
return @tab + code if @ctor
Please sign in to comment.
Something went wrong with that request. Please try again.