Skip to content

Commit a6a5269

Browse files
fix: incorrect await rejection following arrow function in parameters (fixes #13872) (#13928)
* fix: incorrect await rejection following arrow func in params * expressionScope.exit() shifted to end * test added for yield
1 parent 5134505 commit a6a5269

5 files changed

Lines changed: 183 additions & 1 deletion

File tree

packages/babel-parser/src/parser/expression.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2440,9 +2440,9 @@ export default class ExpressionParser extends LValParser {
24402440
},
24412441
);
24422442
this.prodParam.exit();
2443-
this.expressionScope.exit();
24442443
this.state.labels = oldLabels;
24452444
}
2445+
this.expressionScope.exit();
24462446
}
24472447

24482448
isSimpleParamList(
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(function* () {
2+
function f(_=()=>null) {}
3+
yield;
4+
});
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"type": "File",
3+
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":3}},
4+
"program": {
5+
"type": "Program",
6+
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":3}},
7+
"sourceType": "script",
8+
"interpreter": null,
9+
"body": [
10+
{
11+
"type": "ExpressionStatement",
12+
"start":0,"end":56,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":3}},
13+
"expression": {
14+
"type": "FunctionExpression",
15+
"start":1,"end":54,"loc":{"start":{"line":1,"column":1},"end":{"line":4,"column":1}},
16+
"id": null,
17+
"generator": true,
18+
"async": false,
19+
"params": [],
20+
"body": {
21+
"type": "BlockStatement",
22+
"start":14,"end":54,"loc":{"start":{"line":1,"column":14},"end":{"line":4,"column":1}},
23+
"body": [
24+
{
25+
"type": "FunctionDeclaration",
26+
"start":18,"end":43,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":27}},
27+
"id": {
28+
"type": "Identifier",
29+
"start":27,"end":28,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":12},"identifierName":"f"},
30+
"name": "f"
31+
},
32+
"generator": false,
33+
"async": false,
34+
"params": [
35+
{
36+
"type": "AssignmentPattern",
37+
"start":29,"end":39,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":23}},
38+
"left": {
39+
"type": "Identifier",
40+
"start":29,"end":30,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":14},"identifierName":"_"},
41+
"name": "_"
42+
},
43+
"right": {
44+
"type": "ArrowFunctionExpression",
45+
"start":31,"end":39,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":23}},
46+
"id": null,
47+
"generator": false,
48+
"async": false,
49+
"params": [],
50+
"body": {
51+
"type": "NullLiteral",
52+
"start":35,"end":39,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":23}}
53+
}
54+
}
55+
}
56+
],
57+
"body": {
58+
"type": "BlockStatement",
59+
"start":41,"end":43,"loc":{"start":{"line":2,"column":25},"end":{"line":2,"column":27}},
60+
"body": [],
61+
"directives": []
62+
}
63+
},
64+
{
65+
"type": "ExpressionStatement",
66+
"start":46,"end":52,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":8}},
67+
"expression": {
68+
"type": "YieldExpression",
69+
"start":46,"end":51,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":7}},
70+
"delegate": false,
71+
"argument": null
72+
}
73+
}
74+
],
75+
"directives": []
76+
},
77+
"extra": {
78+
"parenthesized": true,
79+
"parenStart": 0
80+
}
81+
}
82+
}
83+
],
84+
"directives": []
85+
}
86+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(async function () {
2+
function f(_=()=>null) {}
3+
await null;
4+
});
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"type": "File",
3+
"start":0,"end":66,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":3}},
4+
"program": {
5+
"type": "Program",
6+
"start":0,"end":66,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":3}},
7+
"sourceType": "script",
8+
"interpreter": null,
9+
"body": [
10+
{
11+
"type": "ExpressionStatement",
12+
"start":0,"end":66,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":3}},
13+
"expression": {
14+
"type": "FunctionExpression",
15+
"start":1,"end":64,"loc":{"start":{"line":1,"column":1},"end":{"line":4,"column":1}},
16+
"id": null,
17+
"generator": false,
18+
"async": true,
19+
"params": [],
20+
"body": {
21+
"type": "BlockStatement",
22+
"start":19,"end":64,"loc":{"start":{"line":1,"column":19},"end":{"line":4,"column":1}},
23+
"body": [
24+
{
25+
"type": "FunctionDeclaration",
26+
"start":23,"end":48,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":27}},
27+
"id": {
28+
"type": "Identifier",
29+
"start":32,"end":33,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":12},"identifierName":"f"},
30+
"name": "f"
31+
},
32+
"generator": false,
33+
"async": false,
34+
"params": [
35+
{
36+
"type": "AssignmentPattern",
37+
"start":34,"end":44,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":23}},
38+
"left": {
39+
"type": "Identifier",
40+
"start":34,"end":35,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":14},"identifierName":"_"},
41+
"name": "_"
42+
},
43+
"right": {
44+
"type": "ArrowFunctionExpression",
45+
"start":36,"end":44,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":23}},
46+
"id": null,
47+
"generator": false,
48+
"async": false,
49+
"params": [],
50+
"body": {
51+
"type": "NullLiteral",
52+
"start":40,"end":44,"loc":{"start":{"line":2,"column":19},"end":{"line":2,"column":23}}
53+
}
54+
}
55+
}
56+
],
57+
"body": {
58+
"type": "BlockStatement",
59+
"start":46,"end":48,"loc":{"start":{"line":2,"column":25},"end":{"line":2,"column":27}},
60+
"body": [],
61+
"directives": []
62+
}
63+
},
64+
{
65+
"type": "ExpressionStatement",
66+
"start":51,"end":62,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":13}},
67+
"expression": {
68+
"type": "AwaitExpression",
69+
"start":51,"end":61,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":12}},
70+
"argument": {
71+
"type": "NullLiteral",
72+
"start":57,"end":61,"loc":{"start":{"line":3,"column":8},"end":{"line":3,"column":12}}
73+
}
74+
}
75+
}
76+
],
77+
"directives": []
78+
},
79+
"extra": {
80+
"parenthesized": true,
81+
"parenStart": 0
82+
}
83+
}
84+
}
85+
],
86+
"directives": []
87+
}
88+
}

0 commit comments

Comments
 (0)