mirror of
https://github.com/swc-project/swc.git
synced 2024-12-22 21:21:31 +03:00
fix(es/parser): Allow using async
as the first one in parameters (#2386)
This commit is contained in:
parent
ac3fbd91ac
commit
2379fe1ce0
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2687,7 +2687,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "swc_ecma_parser"
|
name = "swc_ecma_parser"
|
||||||
version = "0.73.4"
|
version = "0.73.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"either",
|
"either",
|
||||||
"enum_kind",
|
"enum_kind",
|
||||||
|
@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"]
|
|||||||
license = "Apache-2.0/MIT"
|
license = "Apache-2.0/MIT"
|
||||||
name = "swc_ecma_parser"
|
name = "swc_ecma_parser"
|
||||||
repository = "https://github.com/swc-project/swc.git"
|
repository = "https://github.com/swc-project/swc.git"
|
||||||
version = "0.73.4"
|
version = "0.73.5"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
@ -1266,7 +1266,7 @@ impl<'a, I: Tokens> Parser<I> {
|
|||||||
// as a pattern instead of reparsing)
|
// as a pattern instead of reparsing)
|
||||||
while !eof!(self) && !is!(self, ')') {
|
while !eof!(self) && !is!(self, ')') {
|
||||||
if first {
|
if first {
|
||||||
if is!(self, "async") {
|
if is!(self, "async") && !peeked_is!(self, ',') {
|
||||||
// https://github.com/swc-project/swc/issues/410
|
// https://github.com/swc-project/swc/issues/410
|
||||||
self.state.potential_arrow_start = Some(cur_pos!(self));
|
self.state.potential_arrow_start = Some(cur_pos!(self));
|
||||||
let expr = self.parse_assignment_expr()?;
|
let expr = self.parse_assignment_expr()?;
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
let fn = (async, x) => {};
|
@ -0,0 +1,88 @@
|
|||||||
|
{
|
||||||
|
"type": "Script",
|
||||||
|
"span": {
|
||||||
|
"start": 0,
|
||||||
|
"end": 26,
|
||||||
|
"ctxt": 0
|
||||||
|
},
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"span": {
|
||||||
|
"start": 0,
|
||||||
|
"end": 26,
|
||||||
|
"ctxt": 0
|
||||||
|
},
|
||||||
|
"kind": "let",
|
||||||
|
"declare": false,
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"span": {
|
||||||
|
"start": 4,
|
||||||
|
"end": 25,
|
||||||
|
"ctxt": 0
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"span": {
|
||||||
|
"start": 4,
|
||||||
|
"end": 6,
|
||||||
|
"ctxt": 0
|
||||||
|
},
|
||||||
|
"value": "fn",
|
||||||
|
"optional": false,
|
||||||
|
"typeAnnotation": null
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "ArrowFunctionExpression",
|
||||||
|
"span": {
|
||||||
|
"start": 9,
|
||||||
|
"end": 25,
|
||||||
|
"ctxt": 0
|
||||||
|
},
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"span": {
|
||||||
|
"start": 10,
|
||||||
|
"end": 15,
|
||||||
|
"ctxt": 0
|
||||||
|
},
|
||||||
|
"value": "async",
|
||||||
|
"optional": false,
|
||||||
|
"typeAnnotation": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"span": {
|
||||||
|
"start": 17,
|
||||||
|
"end": 18,
|
||||||
|
"ctxt": 0
|
||||||
|
},
|
||||||
|
"value": "x",
|
||||||
|
"optional": false,
|
||||||
|
"typeAnnotation": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"span": {
|
||||||
|
"start": 23,
|
||||||
|
"end": 25,
|
||||||
|
"ctxt": 0
|
||||||
|
},
|
||||||
|
"stmts": []
|
||||||
|
},
|
||||||
|
"async": false,
|
||||||
|
"generator": false,
|
||||||
|
"typeParameters": null,
|
||||||
|
"returnType": null
|
||||||
|
},
|
||||||
|
"definite": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"interpreter": null
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user