LiveScript icon indicating copy to clipboard operation
LiveScript copied to clipboard

for of loop assigned to object field issue

Open normalser opened this issue 9 years ago • 1 comments

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

normalser avatar Apr 11 '16 19:04 normalser

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

summivox avatar Jun 09 '16 01:06 summivox