Open davidbau opened 10 years ago
hmm, cool, I didn't even know you could do that in CoffeeScript.
Yeah there are now several issues with how for loops are handled, unfortunately. On Dec 5, 2013 11:44 AM, "Chris Coyne" notifications@github.com wrote:
hmm, cool, I didn't even know you could do that in CoffeeScript.
— Reply to this email directly or view it on GitHubhttps://github.com/maxtaco/coffee-script/issues/98#issuecomment-29914111 .
Ouch. My students on pencilcode.net have been running into this issue.
Max, any hints or guidance on where in the code to look to fix the problem? Happy to try to contribute a fix if pointed in the right direction.
Sorry David, life has been crazy with keybase.io launching and us trying to get a beta working. I haven't had any time for anything else, and for this I apologize!
src/nodes.coffee, see class For
, method icedCompiledIced
. That's where
the loop limit rewriting happens. As you can see, it's a full rewrite of
the loop constructs since they are split up over mutually recursive
functions (for the CSP transform).
The directions for developing are the same as for mainline CoffeeScript (https://github.com/jashkenas/coffee-script/wiki/%5BHowto%5D-Hacking-on-the-CoffeeScript-Compiler) though these directions are a bit out-of-date. Also, I suggest running ./bin/cake
rather than the global cake
since there are a few iced-aware additions to the Cakefile.
Thanks David, sorry not to be making any progress on these issues.
The idiom "for [1..10]" is not supported and causes the iced compiler to crash.
To repro:
for [1..10] await setTimeout defer(), 1000 console.log 'hello'
Expect: 10 hellos, one second apart. Got: "CANNOT CALL METHOD 'INVERT' OF NULL"
Notice, (1) commenting the "await" line makes it work without a delay (2) changing it to "for x in [1..10]" makes it work happily.