Remove await* from babel-generator, add parsing error to babylon - (fixes T6688)
This commit is contained in:
@@ -118,7 +118,7 @@ function buildYieldAwait(keyword: string) {
|
||||
return function (node: Object) {
|
||||
this.push(keyword);
|
||||
|
||||
if (node.delegate || node.all) {
|
||||
if (node.delegate) {
|
||||
this.push("*");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
async function foo() {
|
||||
await bar();
|
||||
}
|
||||
|
||||
async function bar() {
|
||||
await* foo();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
async function foo() {
|
||||
await bar();
|
||||
}
|
||||
|
||||
async function bar() {
|
||||
await* foo();
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ let awaitVisitor = {
|
||||
},
|
||||
|
||||
AwaitExpression: function(path) {
|
||||
// Convert await and await* expressions to yield expressions.
|
||||
// Convert await expressions to yield expressions.
|
||||
let argument = path.node.argument;
|
||||
|
||||
// Transforming `await x` to `yield regeneratorRuntime.awrap(x)`
|
||||
|
||||
@@ -968,7 +968,10 @@ pp.parseAwait = function (node) {
|
||||
if (this.isLineTerminator()) {
|
||||
this.unexpected();
|
||||
}
|
||||
node.all = this.eat(tt.star);
|
||||
node.all = false;
|
||||
if (this.match(tt.star)) {
|
||||
this.raise(node.start, "await* has been removed from the async functions proposal. Use Promise.all() instead.")
|
||||
}
|
||||
node.argument = this.parseMaybeUnary();
|
||||
return this.finishNode(node, "AwaitExpression");
|
||||
};
|
||||
|
||||
3
packages/babylon/test/fixtures/experimental/await/illegal-await-star/actual.js
vendored
Normal file
3
packages/babylon/test/fixtures/experimental/await/illegal-await-star/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
async function bar() {
|
||||
await* foo();
|
||||
}
|
||||
4
packages/babylon/test/fixtures/experimental/await/illegal-await-star/options.json
vendored
Normal file
4
packages/babylon/test/fixtures/experimental/await/illegal-await-star/options.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": ["asyncFunctions"],
|
||||
"throws": "await* has been removed from the async functions proposal. Use Promise.all() instead. (2:2)"
|
||||
}
|
||||
Reference in New Issue
Block a user