Permalink
Browse files

the rest of the fix from last night.

  • Loading branch information...
1 parent 186c64e commit 3941b3ed228ac8b40c212f3c7ad15aee85b3c343 @maxtaco committed Jan 20, 2012
Showing with 35 additions and 0 deletions.
  1. +9 −0 lib/coffee-script/nodes.js
  2. +18 −0 src/nodes.coffee
  3. +8 −0 test/tame.coffee

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

Oops, something went wrong.
View
@@ -73,6 +73,18 @@ exports.Base = class Base
if @jumps()
throw SyntaxError 'cannot use a pure statement in an expression.'
o.sharedScope = yes
+
+ #
+ # This solves this case:
+ #
+ # foo = (autocb) ->
+ # x = (i for i in [0..10])
+ # x
+ #
+ # We don't want the autocb to fire in the evaluation of the list
+ # comprehension on the RHS.
+ #
+ @tameClearAutocbFlags()
Closure.wrap(this).compileNode o
# Statements that need CPS translation will have to be split into
@@ -295,6 +307,12 @@ exports.Base = class Base
@tameCpsPivotFlag = true if child.tameWalkCpsPivots()
@tameCpsPivotFlag
+ tameClearAutocbFlags : ->
+ @tameHasAutocbFlag = false
+ @traverseChildren false, (node) ->
+ node.tameHasAutocbFlag = false
+ true
+
# Default implementations of the common node properties and methods. Nodes
# will override these with custom logic, if needed.
children: []
View
@@ -529,3 +529,11 @@ atest 'for + return + autocb', (cb) ->
(i for i in [0..10])
await bar defer v
cb(v[3] is 3, {})
+
+atest 'for + return + autocb (part 2)', (cb) ->
+ bar = (autocb) ->
+ await delay defer()
+ x = (i for i in [0..10])
+ [10..20]
+ await bar defer v
+ cb(v[3] is 13, {})

0 comments on commit 3941b3e

Please sign in to comment.