Permalink
Browse files

fix a bug that chris found, in nested for .. of loops

  • Loading branch information...
maxtaco committed Jan 17, 2012
1 parent 1c84d03 commit 47d6dc25d2ef9a0cb37ae7213d6428515774934f
Showing with 21 additions and 3 deletions.
  1. +3 −2 lib/coffee-script/nodes.js
  2. +2 −1 src/nodes.coffee
  3. +16 −0 test/tame.coffee

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -2552,7 +2552,8 @@ exports.For = class For extends While
a2 = new Assign keys_val, loop_keys
# _i = 0
- ival = new Value new Literal 'i'
+ iname = scope.freeVariable 'i'
+ ival = new Value new Literal iname
a3 = new Assign ival, new Value new Literal 0
init = [ a1, a2, a3 ]
View
@@ -506,3 +506,19 @@ atest 'super with no args', (cb) ->
await a.foo defer()
cb(a.x is 10, {})
+atest 'nested for .. of .. loops', (cb) ->
+ x =
+ christian:
+ age: 36
+ last: "rudder"
+ max:
+ age: 34
+ last: "krohn"
+
+ tot = 0
+ for first, info of x
+ tot += info.age
+ for k,v of info
+ await delay defer()
+ tot++
+ cb(tot is 74, {})

0 comments on commit 47d6dc2

Please sign in to comment.