Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a bug for for i in [0...N] await ... #40

Closed
neutra opened this issue Sep 16, 2012 · 0 comments
Closed

a bug for for i in [0...N] await ... #40

neutra opened this issue Sep 16, 2012 · 0 comments

Comments

@neutra
Copy link

neutra commented Sep 16, 2012

we know that in coffeescript/iced
[0...4] is [0,1,2,3], and [0..3] is [0,1,2,3] too.
but follow code make different result:
x = []
fun1 = (cb) -> cb 1
for i in [0..3]
await fun1 defer(x[i])
==> x is [1,1,1,1]
for i in [0,1,2,3]
await fun1 defer(x[i])
==> x is [1,1,1,1]

for i in [0...4]
await fun1 defer(x[i])
x is [1,1,1,1,1]

i found that "for i in [0...4] await ..." generate js code like
....
if (!(i <= 4)) {
return _break();
} else {
.....
and iced "for i in [0..3] await ..." generate code all the same except it's 3 rather than 4.
....
if (!(i <= 3)) {
return _break();
} else {
.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants