Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit a294afa

Browse files
azzJamesHenry
authored andcommitted
Fix: Set async on async FunctionExpressions (fixes #244) (#245)
1 parent 7c00f16 commit a294afa

File tree

3 files changed

+333
-1
lines changed

3 files changed

+333
-1
lines changed

lib/ast-converter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ module.exports = function(ast, extra) {
12951295
generator: !!node.asteriskToken,
12961296
params: node.parameters.map(convertChild),
12971297
body: convertChild(node.body),
1298-
async: hasModifier(SyntaxKind.AbstractKeyword, node),
1298+
async: hasModifier(SyntaxKind.AsyncKeyword, node),
12991299
expression: false
13001300
});
13011301
// Process returnType
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
module.exports = {
2+
"type": "Program",
3+
"range": [
4+
0,
5+
30
6+
],
7+
"loc": {
8+
"start": {
9+
"line": 1,
10+
"column": 0
11+
},
12+
"end": {
13+
"line": 2,
14+
"column": 5
15+
}
16+
},
17+
"body": [
18+
{
19+
"type": "ExpressionStatement",
20+
"range": [
21+
0,
22+
30
23+
],
24+
"loc": {
25+
"start": {
26+
"line": 1,
27+
"column": 0
28+
},
29+
"end": {
30+
"line": 2,
31+
"column": 5
32+
}
33+
},
34+
"expression": {
35+
"type": "CallExpression",
36+
"range": [
37+
0,
38+
29
39+
],
40+
"loc": {
41+
"start": {
42+
"line": 1,
43+
"column": 0
44+
},
45+
"end": {
46+
"line": 2,
47+
"column": 4
48+
}
49+
},
50+
"callee": {
51+
"type": "FunctionExpression",
52+
"range": [
53+
1,
54+
26
55+
],
56+
"loc": {
57+
"start": {
58+
"line": 1,
59+
"column": 1
60+
},
61+
"end": {
62+
"line": 2,
63+
"column": 1
64+
}
65+
},
66+
"id": {
67+
"type": "Identifier",
68+
"range": [
69+
16,
70+
20
71+
],
72+
"loc": {
73+
"start": {
74+
"line": 1,
75+
"column": 16
76+
},
77+
"end": {
78+
"line": 1,
79+
"column": 20
80+
}
81+
},
82+
"name": "test"
83+
},
84+
"generator": false,
85+
"params": [],
86+
"body": {
87+
"type": "BlockStatement",
88+
"range": [
89+
23,
90+
26
91+
],
92+
"loc": {
93+
"start": {
94+
"line": 1,
95+
"column": 23
96+
},
97+
"end": {
98+
"line": 2,
99+
"column": 1
100+
}
101+
},
102+
"body": []
103+
},
104+
"async": true,
105+
"expression": false
106+
},
107+
"arguments": []
108+
}
109+
}
110+
],
111+
"sourceType": "script",
112+
"tokens": [
113+
{
114+
"type": "Punctuator",
115+
"value": "(",
116+
"range": [
117+
0,
118+
1
119+
],
120+
"loc": {
121+
"start": {
122+
"line": 1,
123+
"column": 0
124+
},
125+
"end": {
126+
"line": 1,
127+
"column": 1
128+
}
129+
}
130+
},
131+
{
132+
"type": "Identifier",
133+
"value": "async",
134+
"range": [
135+
1,
136+
6
137+
],
138+
"loc": {
139+
"start": {
140+
"line": 1,
141+
"column": 1
142+
},
143+
"end": {
144+
"line": 1,
145+
"column": 6
146+
}
147+
}
148+
},
149+
{
150+
"type": "Keyword",
151+
"value": "function",
152+
"range": [
153+
7,
154+
15
155+
],
156+
"loc": {
157+
"start": {
158+
"line": 1,
159+
"column": 7
160+
},
161+
"end": {
162+
"line": 1,
163+
"column": 15
164+
}
165+
}
166+
},
167+
{
168+
"type": "Identifier",
169+
"value": "test",
170+
"range": [
171+
16,
172+
20
173+
],
174+
"loc": {
175+
"start": {
176+
"line": 1,
177+
"column": 16
178+
},
179+
"end": {
180+
"line": 1,
181+
"column": 20
182+
}
183+
}
184+
},
185+
{
186+
"type": "Punctuator",
187+
"value": "(",
188+
"range": [
189+
20,
190+
21
191+
],
192+
"loc": {
193+
"start": {
194+
"line": 1,
195+
"column": 20
196+
},
197+
"end": {
198+
"line": 1,
199+
"column": 21
200+
}
201+
}
202+
},
203+
{
204+
"type": "Punctuator",
205+
"value": ")",
206+
"range": [
207+
21,
208+
22
209+
],
210+
"loc": {
211+
"start": {
212+
"line": 1,
213+
"column": 21
214+
},
215+
"end": {
216+
"line": 1,
217+
"column": 22
218+
}
219+
}
220+
},
221+
{
222+
"type": "Punctuator",
223+
"value": "{",
224+
"range": [
225+
23,
226+
24
227+
],
228+
"loc": {
229+
"start": {
230+
"line": 1,
231+
"column": 23
232+
},
233+
"end": {
234+
"line": 1,
235+
"column": 24
236+
}
237+
}
238+
},
239+
{
240+
"type": "Punctuator",
241+
"value": "}",
242+
"range": [
243+
25,
244+
26
245+
],
246+
"loc": {
247+
"start": {
248+
"line": 2,
249+
"column": 0
250+
},
251+
"end": {
252+
"line": 2,
253+
"column": 1
254+
}
255+
}
256+
},
257+
{
258+
"type": "Punctuator",
259+
"value": ")",
260+
"range": [
261+
26,
262+
27
263+
],
264+
"loc": {
265+
"start": {
266+
"line": 2,
267+
"column": 1
268+
},
269+
"end": {
270+
"line": 2,
271+
"column": 2
272+
}
273+
}
274+
},
275+
{
276+
"type": "Punctuator",
277+
"value": "(",
278+
"range": [
279+
27,
280+
28
281+
],
282+
"loc": {
283+
"start": {
284+
"line": 2,
285+
"column": 2
286+
},
287+
"end": {
288+
"line": 2,
289+
"column": 3
290+
}
291+
}
292+
},
293+
{
294+
"type": "Punctuator",
295+
"value": ")",
296+
"range": [
297+
28,
298+
29
299+
],
300+
"loc": {
301+
"start": {
302+
"line": 2,
303+
"column": 3
304+
},
305+
"end": {
306+
"line": 2,
307+
"column": 4
308+
}
309+
}
310+
},
311+
{
312+
"type": "Punctuator",
313+
"value": ";",
314+
"range": [
315+
29,
316+
30
317+
],
318+
"loc": {
319+
"start": {
320+
"line": 2,
321+
"column": 4
322+
},
323+
"end": {
324+
"line": 2,
325+
"column": 5
326+
}
327+
}
328+
}
329+
]
330+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
(async function test() {
2+
})();

0 commit comments

Comments
 (0)