Permalink
Browse files

fix a bug that cropped up as part of the rebase

  • Loading branch information...
1 parent 2233f07 commit 3ca31bae56d04ce64f1cf99c4c96b5e6c7985405 @maxtaco committed Jan 4, 2012
Showing with 21 additions and 21 deletions.
  1. +8 −8 lib/coffee-script/nodes.js
  2. +6 −6 src/nodes.coffee
  3. +7 −7 test/tame.coffee
View

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

Oops, something went wrong.
View
@@ -2553,20 +2553,20 @@ exports.For = class For extends While
# Handle the case of 'for i,blah in arr'
else if ! @range and @name
- ival = new Value new Literal d.ivar
+ kval = new Value new Literal d.kvar
len = scope.freeVariable 'len'
ref = scope.freeVariable 'ref'
ref_val = new Value new Literal ref
len_val = new Value new Literal len
a1 = new Assign ref_val, @source
len_rhs = ref_val.copy().add new Access new Value new Literal "length"
a2 = new Assign len_val, len_rhs
- a3 = new Assign ival, new Value new Literal 0
+ a3 = new Assign kval, new Value new Literal 0
init = [ a1, a2, a3 ]
- condition = new Op '<', ival, len_val
- step = new Op '++', ival
+ condition = new Op '<', kval, len_val
+ step = new Op '++', kval
ref_val_copy = ref_val.copy()
- ref_val_copy.add new Index ival
+ ref_val_copy.add new Index kval
a4 = new Assign @name, ref_val_copy
body.unshift a4
@@ -2600,7 +2600,7 @@ exports.For = class For extends While
defPart = ''
idt1 = @tab + TAB
- return code if code = @compileTame o, { ivar, stepvar, body, rvar }
+ return code if code = @compileTame o, { stepvar, body, rvar, kvar }
if @range
forPart = source.compile merge(o, {index: ivar, name, @step})
View
@@ -64,13 +64,13 @@ atest "for k,v of obj testing", (cb) ->
s += k + " " + v + " "
cb( s is "the quick brown fox jumped over ", {} )
-#atest "for k,v in arr testing", (cb) ->
-# obj = [ "the", "quick", "brown" ]
-# s = ""
-# for v,i in obj
-# await delay defer()
-# s += v + " " + i + " "
-# cb( s is "the 0 quick 1 brown 2 ", {} )
+atest "for k,v in arr testing", (cb) ->
+ obj = [ "the", "quick", "brown" ]
+ s = ""
+ for v,i in obj
+ await delay defer()
+ s += v + " " + i + " "
+ cb( s is "the 0 quick 1 brown 2 ", {} )
atest "switch-a-roos", (cb) ->
res = 0

0 comments on commit 3ca31ba

Please sign in to comment.