Skip to content

Incorrect minification within try block and destructuring #871

@nachoab

Description

@nachoab

This function is incorrectly minified. It happens when using 2 variables and not using one:

async function example() {
  var foo, bar;
  try {
    [foo, bar] = await Promise.all([req(1), req(2)]);
  } catch(e) {}
  console.log(foo);
}

Actual Output
foo and bar and ignored, so the output is broken

async function example() {
  var a;
  try {
    await Promise.all([req(1), req(2)]);
  } catch (c) {}
  console.log(a);
}

See it here:

https://babeljs.io/repl/#?babili=true&browsers=&build=&builtIns=false&code_lz=IYZwngdgxgBAZgV2gFwJYHsIwKYA9gC2ADgDbYAUAlDAN4BQMMAbsAE7zroA0MARmwG4GMZKzC1hjANpxOPfqwC6MALwxgAd2CpkMAAqt0BVCGwA6YCRLkprbAEdyARko87jgEyVFlIYwC-MFDAyFAAFuTY1DT-wlCYIOhkZiToAObksui-dP5AA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&lineWrap=false&presets=babili&prettier=true&targets=&version=6.26.0&envVersion=

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions