test262/test/language/statements/for/head-const-bound-names-in-stmt.js
Dmitriy Kubyshkin ba5529d926
Fix wrong error for a lexical redeclaration test (#3575)
The test as originally specified fails in all compatible parsers, but for the wrong reason. Below is an excerpt from V8, but all parser I tested behave the same:

```js
for (const x; false; ) {
           ^
SyntaxError: Missing initializer in const declaration
```

After the change the error is the assumed:

```js
  var x;
      ^
SyntaxError: Identifier 'x' has already been declared
```
2022-06-16 22:24:51 -04:00

23 lines
608 B
JavaScript

// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: The body may not re-declare variables declared in the head
info: |
IterationStatement :
for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
It is a Syntax Error if any element of the BoundNames of LexicalDeclaration
also occurs in the VarDeclaredNames of Statement.
negative:
phase: parse
type: SyntaxError
esid: sec-for-statement
es6id: 13.7.4
---*/
$DONOTEVALUATE();
for (const x = 0; false; ) {
var x;
}