Skip to content

[Bug]: babel crashes when destructuring, after using for await inside of async IIFE #13801

@danieltroger

Description

@danieltroger

💻

  • Would you like to work on a fix?

How are you using Babel?

Other (Next.js, Gatsby, vue-cli, ...)

Input code

Code that reproduces the crash (only happens when targeting older engines like IE 11:

main();

async function main() {
  let is_done = false;
  const async_iterable = {
    [Symbol.asyncIterator]: () => ({
      next: () => {
        const promise = Promise.resolve({ value: "luv u", done: is_done });
        is_done = true;
        return promise;
      },
    }),
  };


  (async () => { // IIFE: required for babel to crash
    for await (const string of async_iterable) { // for await: required for babel to crash
      console.log(string);
    }
  })();

  const [one] = [1]; // array destructuring: required for babel to crash
}

REPL link that also crashes

Configuration file name

babel.config.js

Configuration

Not relevant IMO since it also crashes in REPL. Target has to be set to IE 11.

Current and expected behavior

Current behavior: Property name expected type of string but got null

Expected behavior: Code that prints luv u to the console when ran.

Environment

  • Babel: 7.15.7 (@babel/core 7.15.5)
  • Node v16.9.1
  • Yarn 3.0.2
  • OS: macOS 10.15.7 (19H1323)

Possible solution

Transpile the code correctly instead of crashing

Additional context

I wrote code which was the reproduction code but with many more steps. Wanted to push it to a customer as a quick fix before my next calendar event. Babel crashed. Suck. Deployed only for modern browsers. Bored, offline on a flight I removed code bit for bit for bit for bit until I came up with the reproduction snippet. This is a very weird bug.

Metadata

Metadata

Assignees

Labels

outdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: traverse

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions