mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Reset @seenFor in lexer before tokenizing
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user