Rich-Harris / butternut

The fast, future-friendly minifier

Home Page:https://butternut.now.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug w/ async + arrow functions + object destructuring

jeffposnick opened this issue · comments

butternut 0.1.0 minifies the following code

const asyncArrowFunction = async ({value}) => {
  console.log(`value is ${value}`);
};

asyncArrowFunction({value: 1});

to

let asyncArrowFunction=async {value:g})=>{console.log(`value is ${g}`)};asyncArrowFunction({value:1})

The async { in that output should be async ({, and without that missing ( character, the output isn't valid JavaScript.

This bug seems specific to the combination of all three of the async keyword, arrow functions, and object destructuring of parameter passed to the function. If only two of those are used (e.g. async and arrow functions, without object destructuring for the parameter), then the output minifies properly.