diff --git a/lib/nodes.js b/lib/nodes.js index d20252a4..e5c7c241 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -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; } diff --git a/src/nodes.coffee b/src/nodes.coffee index 82f32ea6..7eb493e4 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -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']