-
Notifications
You must be signed in to change notification settings - Fork 48
wtfcs
Nami-Doc edited this page Apr 1, 2013
·
27 revisions
- https://github.com/jashkenas/coffee-script/issues/712
-
https://github.com/jashkenas/coffee-script/issues/1606 and other
super
issues
$ coffee -s
if 0
if 0
console.log 1
console.log 2
console.log 3
3
cf.
$ python <<_
> if 0:
> if 0:
> print(1)
> print(2)
> print(3)
> _
File "<stdin>", line 4
print(2)
^
IndentationError: unindent does not match any outer indentation level
$ coffee -e 'console.log(i+j for j in [3..4] for i in [1..2])'
[ [ 4, 5 ], [ 5, 6 ] ]
cf.
js> uneval([i+j for each(i in [1,2]) for each(j in [3,4])])
[4, 5, 5, 6]
http://brehaut.net/blog/2011/coffeescript_comprehensions
$ coffee -e 'console.log i for i in [3..1]'
3
2
1
$ coffee -e 'console.log i for i in [3..1] by 1'
$ coffee -e 'console.log i for i in ([3..1]) by 1'
3
2
1
$ coffee -e 'console.log i for i in [3..1] by (1)'
3
4
5
6
...
$ coffee -e '{"#{k}": v}'
Error: Parse error on line 1: Unexpected '('
$ coffee -bce 'a if b if c'
// Generated by CoffeeScript 1.3.3
if (c ? b : void 0) {
a;
}
$ coffee -e 'i = 0; console.log i if i%2 while 6 > i += 1'
6
cf.
$ ruby -e 'i = 0; p i if i.odd? while 6 > i += 1'
1
3
5
$ coffee -e 'spaces = / +/'
Error: Parse error on line 1: Unexpected 'MATH'
$ coffee -bce 'invalid = /+/'
// Generated by CoffeeScript 1.3.3
var invalid;
invalid = /+/;
cf.
$ node -e '/ +/'
/ +/
$ node -e '/+/'
undefined:1
^
SyntaxError: Invalid regular expression: /+/: Nothing to repeat
$ coffee -bce '# 1'
// Generated by CoffeeScript 1.3.3
$ coffee -bce '## 2'
// Generated by CoffeeScript 1.3.3
$ coffee -bce '### 3'
// Generated by CoffeeScript 1.3.3
/* 3
*/
$ coffee -bce '#### 4'
// Generated by CoffeeScript 1.3.3
$ coffee -bce '###*/ 5'
SyntaxError: block comment cannot contain "*/", starting on line 1
...
$ coffee -bce '6 ### ###'
Error: Parse error on line 1: Unexpected 'HERECOMMENT'
...