Skip to content

[Bug]: unexpected error when attempting to destructure initializer with a "hole"  #14239

@magic-akari

Description

@magic-akari

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

REPL

var iterCount = 0;

for (const [x = 23] = [,]; iterCount < 1; ) {
  assert.sameValue(x, 23);
  // another statement

  iterCount += 1;
}

assert.sameValue(iterCount, 1, 'Iteration occurred as expected');

Configuration file name

.babelrc

Configuration

env targets: chrome 50

Current and expected behavior

Current behavior:

'Const declarations' require an initialization value. (5:16)
  3 | var iterCount = 0;
  4 |
> 5 | for (const _ref, x = _ref === void 0 ? 23 : _ref; iterCount < 1;) {
    |                ^
  6 |   assert.sameValue(x, 23); // another statement
  7 |
  8 |   iterCount += 1;

expect behavior:
compile without error.

Environment

Babel Playground.

Possible solution

No response

Additional context

This is a test case from test262.

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions