LiveScript
LiveScript copied to clipboard
for of loop assigned to object field issue
Hi,
Sorry if duplicate (couldn't find one):
a: for x,y of {} => x => Fails with Unexpected '}'
a: for x of {} => x => Works fine
a= for x,y of {} => x => Works fine
a: for x,y in [] => x => Works fine
The problem occurs at lexer rewrite pass. Specifically regarding implicit object. The comma after x is interpreted as field separator of the implicit object (my mistake, not the real reason) rather than a part of the loophead.
IMHO this is (yet again) a problem with current (hacky) lexer design. It has something to do with how for loop is handled right now, which I planned to fix (but couldn't find time as it's a big change).
Tokens after rewrite:
{ ID:a : FOR: ID:x }: , ID:y OF { } INDENT:0 ID:x DEDENT:0 NEWLINE:\n