mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
disallow index mentions for range loops.
This commit is contained in:
parent
c3f1820ebc
commit
b52a1ed60a
2 changed files with 6 additions and 2 deletions
|
@ -1716,8 +1716,11 @@
|
|||
}
|
||||
this.range = this.source instanceof Value && this.source.base instanceof Range && !this.source.properties.length;
|
||||
this.pattern = this.name instanceof Value;
|
||||
if (this.range && this.index) {
|
||||
throw SyntaxError('indexes do not apply to range loops');
|
||||
}
|
||||
if (this.range && this.pattern) {
|
||||
throw SyntaxError('cannot pattern match a range loop');
|
||||
throw SyntaxError('cannot pattern match over range loops');
|
||||
}
|
||||
this.returns = false;
|
||||
}
|
||||
|
|
|
@ -1380,7 +1380,8 @@ exports.For = class For extends Base
|
|||
throw SyntaxError 'index cannot be a pattern matching expression' if @index instanceof Value
|
||||
@range = @source instanceof Value and @source.base instanceof Range and not @source.properties.length
|
||||
@pattern = @name instanceof Value
|
||||
throw SyntaxError 'cannot pattern match a range loop' if @range and @pattern
|
||||
throw SyntaxError 'indexes do not apply to range loops' if @range and @index
|
||||
throw SyntaxError 'cannot pattern match over range loops' if @range and @pattern
|
||||
@returns = false
|
||||
|
||||
children: ['body', 'source', 'guard', 'step']
|
||||
|
|
Loading…
Reference in a new issue