Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Class Field Initializer should not allow await expression as imm…
…ediate child (#10946) * fix: scope.inAsync should exclude reference in class property initializers * chore: add test on await in computed class property * fix flow error :(
- Loading branch information
Showing
17 changed files
with
1,348 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...ges/babel-parser/test/fixtures/es2017/async-functions/await-inside-class-methods/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
() => class { | ||
async m() { await 42 } | ||
} |
210 changes: 210 additions & 0 deletions
210
.../babel-parser/test/fixtures/es2017/async-functions/await-inside-class-methods/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 40, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 1 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 40, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 1 | ||
} | ||
}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start": 0, | ||
"end": 40, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 1 | ||
} | ||
}, | ||
"expression": { | ||
"type": "ArrowFunctionExpression", | ||
"start": 0, | ||
"end": 40, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 1 | ||
} | ||
}, | ||
"id": null, | ||
"generator": false, | ||
"async": false, | ||
"params": [], | ||
"body": { | ||
"type": "ClassExpression", | ||
"start": 6, | ||
"end": 40, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 6 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 1 | ||
} | ||
}, | ||
"id": null, | ||
"superClass": null, | ||
"body": { | ||
"type": "ClassBody", | ||
"start": 12, | ||
"end": 40, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 12 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 1 | ||
} | ||
}, | ||
"body": [ | ||
{ | ||
"type": "ClassMethod", | ||
"start": 16, | ||
"end": 38, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 24 | ||
} | ||
}, | ||
"static": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start": 22, | ||
"end": 23, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 8 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 9 | ||
}, | ||
"identifierName": "m" | ||
}, | ||
"name": "m" | ||
}, | ||
"computed": false, | ||
"kind": "method", | ||
"id": null, | ||
"generator": false, | ||
"async": true, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start": 26, | ||
"end": 38, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 12 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 24 | ||
} | ||
}, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start": 28, | ||
"end": 36, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 14 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 22 | ||
} | ||
}, | ||
"expression": { | ||
"type": "AwaitExpression", | ||
"start": 28, | ||
"end": 36, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 14 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 22 | ||
} | ||
}, | ||
"argument": { | ||
"type": "NumericLiteral", | ||
"start": 34, | ||
"end": 36, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 20 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 22 | ||
} | ||
}, | ||
"extra": { | ||
"rawValue": 42, | ||
"raw": "42" | ||
}, | ||
"value": 42 | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...parser/test/fixtures/es2017/async-functions/await-inside-computed-class-property/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
async () => class { | ||
[await 42]() { } | ||
} |
Oops, something went wrong.