Skip to content

Commit

Permalink
Change the precedence of await so it's the same as other unary expres…
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou authored and michaelficarra committed Jan 8, 2019
1 parent 52df4da commit f6df59f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion escodegen.js
Expand Up @@ -82,7 +82,6 @@
Precedence = {
Sequence: 0,
Yield: 1,
Await: 1,
Assignment: 1,
Conditional: 2,
ArrowFunction: 2,
Expand All @@ -96,6 +95,7 @@
BitwiseSHIFT: 10,
Additive: 11,
Multiplicative: 12,
Await: 13,
Unary: 13,
Postfix: 14,
Call: 15,
Expand Down
40 changes: 40 additions & 0 deletions test/harmony.js
Expand Up @@ -5927,6 +5927,46 @@ data = {
}
},

'async function test() {\n await (foo ? bar : quux);\n}': {
generateFrom: {
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "test"
},
"params": [],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "AwaitExpression",
"argument": {
"type": "ConditionalExpression",
"test": {
"type": "Identifier",
"name": "foo"
},
"consequent": {
"type": "Identifier",
"name": "bar"
},
"alternate": {
"type": "Identifier",
"name": "quux"
}
}
}
}
]
},
"generator": false,
"expression": false,
"async": true
}
},

'f(async function (promise) {\n await promise;\n});': {
generateFrom: {
"type": "ExpressionStatement",
Expand Down

0 comments on commit f6df59f

Please sign in to comment.