Reset @seenFor in lexer before tokenizing

This commit is contained in:
Jeremy Ruten
2015-07-07 19:55:43 -06:00
parent 342b395b0a
commit 3d7d68a766
3 changed files with 6 additions and 0 deletions

View File

@@ -23,6 +23,7 @@
this.indents = [];
this.ends = [];
this.tokens = [];
this.seenFor = false;
this.chunkLine = opts.line || 0;
this.chunkColumn = opts.column || 0;
code = this.clean(code);

View File

@@ -42,6 +42,7 @@ exports.Lexer = class Lexer
@indents = [] # The stack of all current indentation levels.
@ends = [] # The stack for pairing up tokens.
@tokens = [] # Stream of parsed tokens in the form `['TYPE', value, location data]`.
@seenFor = no # Used to recognize FORIN and FOROF tokens.
@chunkLine =
opts.line or 0 # The start line for the current @chunk.

View File

@@ -215,6 +215,10 @@ test "#1714: lexer bug with raw range `for` followed by `in`", ->
0 for [1..10] # comment ending
ok not ('a' in ['b'])
# lexer state (specifically @seenFor) should be reset before each compilation
CoffeeScript.compile "0 for [1..2]"
CoffeeScript.compile "'a' in ['b']"
test "#1099: statically determined `not in []` reporting incorrect result", ->
ok 0 not in []