google / traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler
Apache License 2.0
8.18k stars 580 forks source link

Wrong assignment in await statements #1934

Closed arcanis closed 9 years ago

arcanis commented 9 years ago

The following code doesn't work (cf repl). It alerts the function replace instead of the result of the function call.

async function test() {
  return await new Promise( ( resolve, reject ) => {

      let escapedQuery = "test".replace( /[\\&|!(){}[\]^"~*?:+-]/g, '\\$1' );
      alert( escapedQuery );

  } );
}

test()
arv commented 9 years ago

The explode transformer is failing to add parens.

What we have now is:

var x = expressionThatNeedsToBeExpanded;

which gets turned into:

var x = a, remainder;

we need to ensure that we get:

var x = (a, remainder);
arv commented 9 years ago

Actually, the problem is that we should not expand the function body (or params).

There are other bugs related to missing parens but not for generators/async functions.