maxtaco / coffee-script

IcedCoffeeScript
http://maxtaco.github.com/coffee-script
MIT License
727 stars 58 forks source link

Negative stride does not work in iced. #86

Closed davidbau closed 11 years ago

davidbau commented 11 years ago

Example code:

for x in [3..1]
  console.log x
  await setTimeout defer(), 1000

http://goo.gl/6Cflk1

Expect: should take a few seconds to write 3, 2, 1. Actual: a couple problems in the generated code. (1) With 2 dots, coffeescript knows how to generate backwards ranges even without "by", but iced doesn't know that the stride should be assumed to be -1. (2) Then when the stride is negative, iced coffeescript should flip the inequality termination test from !(x <= 1) to !(x >= 1).

Other similar forms are also broken. With 3 dots, coffeescript requires "by", but the negative stride doesn't work in iced.

for x in [3...0] by -1
  console.log x
  await setTimeout defer(), 1000
maxtaco commented 11 years ago

BTW, I deleted iced-coffee-script/iced-coffee-script so it doesn't cause future confusion. In the end, I decided to keep things where they are to maintain the issues lists, etc.

maxtaco commented 11 years ago

And pushed live to npm in 1.6.3-g