Skip to content

Commit

Permalink
Allow await in a yield expression.
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Mar 25, 2020
1 parent 14bff20 commit 0131bca
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ecmascript/parser/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl Debug for Word {
#[kind(function(before_expr = "bool", starts_expr = "bool"))]
pub enum Keyword {
/// Spec says this might be identifier.
#[kind(before_expr)]
#[kind(before_expr, starts_expr)]
Await,

Break,
Expand Down
3 changes: 3 additions & 0 deletions ecmascript/parser/tests/jsx/basic/custom/issue-720/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
async function* main() {
yield await 0;
}
81 changes: 81 additions & 0 deletions ecmascript/parser/tests/jsx/basic/custom/issue-720/input.js.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 45,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 16,
"end": 20,
"ctxt": 0
},
"value": "main",
"typeAnnotation": null,
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 0,
"end": 45,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 23,
"end": 45,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 29,
"end": 43,
"ctxt": 0
},
"expression": {
"type": "YieldExpression",
"span": {
"start": 29,
"end": 42,
"ctxt": 0
},
"argument": {
"type": "AwaitExpression",
"span": {
"start": 35,
"end": 42,
"ctxt": 0
},
"argument": {
"type": "NumericLiteral",
"span": {
"start": 41,
"end": 42,
"ctxt": 0
},
"value": 0.0
}
},
"delegate": false
}
}
]
},
"generator": true,
"async": true,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}
3 changes: 3 additions & 0 deletions ecmascript/parser/tests/typescript/custom/issue-720/input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
async function* main() {
yield await 0;
}
81 changes: 81 additions & 0 deletions ecmascript/parser/tests/typescript/custom/issue-720/input.ts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 45,
"ctxt": 0
},
"body": [
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 16,
"end": 20,
"ctxt": 0
},
"value": "main",
"typeAnnotation": null,
"optional": false
},
"declare": false,
"params": [],
"decorators": [],
"span": {
"start": 0,
"end": 45,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 23,
"end": 45,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 29,
"end": 43,
"ctxt": 0
},
"expression": {
"type": "YieldExpression",
"span": {
"start": 29,
"end": 42,
"ctxt": 0
},
"argument": {
"type": "AwaitExpression",
"span": {
"start": 35,
"end": 42,
"ctxt": 0
},
"argument": {
"type": "NumericLiteral",
"span": {
"start": 41,
"end": 42,
"ctxt": 0
},
"value": 0.0
}
},
"delegate": false
}
}
]
},
"generator": true,
"async": true,
"typeParameters": null,
"returnType": null
}
],
"interpreter": null
}

0 comments on commit 0131bca

Please sign in to comment.