Issue #1714 ... broken 'in' after raw range 'for'

This commit is contained in:
Jeremy Ashkenas 2011-09-20 22:28:07 -05:00
parent a2c593bc2c
commit 54110c98d9
3 changed files with 6 additions and 0 deletions

View File

@ -238,6 +238,7 @@
if (!(match = MULTI_DENT.exec(this.chunk))) return 0;
indent = match[0];
this.line += count(indent, '\n');
this.seenFor = false;
prev = last(this.tokens, 1);
size = indent.length - 1 - indent.lastIndexOf('\n');
noNewlines = this.unfinished();

View File

@ -241,6 +241,7 @@ exports.Lexer = class Lexer
return 0 unless match = MULTI_DENT.exec @chunk
indent = match[0]
@line += count indent, '\n'
@seenFor = no
prev = last @tokens, 1
size = indent.length - 1 - indent.lastIndexOf '\n'
noNewlines = @unfinished()

View File

@ -199,6 +199,10 @@ test "#1100: precedence in or-test compilation of `in`", ->
test "#1630: `in` should check `hasOwnProperty`", ->
ok undefined not in length: 1
test "#1714: lexer bug with raw range `for` followed by `in`", ->
0 for [1..10]
ok not ('a' in ['b'])
# Chained Comparison