Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add more test cases. more fixups to the scoping system.

  • Loading branch information...
commit e90ffb380aa5ae339c083760fe85d4920ac6ae61 1 parent d4fe65b
@maxtaco authored
View
8 lib/coffee-script/nodes.js
@@ -1739,7 +1739,7 @@
};
Code.prototype.compileNode = function(o) {
- var code, exprs, i, idt, lit, p, param, ref, splats, v, val, vars, wasEmpty, _i, _j, _k, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6;
+ var code, exprs, i, idt, lit, p, param, ref, splats, stored_tamed_scope, v, val, vars, wasEmpty, _i, _j, _k, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6;
o.scope = new Scope(o.scope, this.body, this);
o.scope.shared = del(o, 'sharedScope');
o.indent += TAB;
@@ -1809,11 +1809,15 @@
code = 'function';
if (this.ctor) code += ' ' + this.name;
code += '(' + vars.join(', ') + ') {';
- if (!this.tamegen) o.tamed_scope = this.tameNodeFlag ? o.scope : null;
+ if (!this.tamegen) {
+ stored_tamed_scope = o.tamed_scope;
+ o.tamed_scope = this.tameNodeFlag ? o.scope : null;
+ }
if (!this.body.isEmpty()) {
code += "\n" + (this.body.compileWithDeclarations(o)) + "\n" + this.tab;
}
code += '}';
+ o.tamed_scope = stored_tamed_scope;
if (this.ctor) return this.tab + code;
if (this.front || (o.level >= LEVEL_ACCESS)) {
return "(" + code + ")";
View
2  src/nodes.coffee
@@ -1481,11 +1481,13 @@ exports.Code = class Code extends Base
code += '(' + vars.join(', ') + ') {'
unless @tamegen
+ stored_tamed_scope = o.tamed_scope
o.tamed_scope = if @tameNodeFlag then o.scope else null
>>>>>>> betteR! gotta run, but close!
code += "\n#{ @body.compileWithDeclarations o }\n#{@tab}" unless @body.isEmpty()
code += '}'
+ o.tamed_scope = stored_tamed_scope
return @tab + code if @ctor
if @front or (o.level >= LEVEL_ACCESS) then "(#{code})" else code
View
9 test/tame.coffee
@@ -201,3 +201,12 @@ atest "AT variable works in an await (2)", (cb) ->
o = new MyClass
await o.run defer()
cb(o.getVal() == 10, {})
+
+atest "loops respect autocbs", (cb) ->
+ ok = false
+ bar = (autocb) ->
+ for i in [0..10]
+ await delay defer()
+ ok = true
+ await bar defer()
+ cb(ok, {})
Please sign in to comment.
Something went wrong with that request. Please try again.