Skip to content

Commit 47d033b

Browse files
committed
test parenthesized named function
1 parent 2c93848 commit 47d033b

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

src/parse.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ export class CellParser extends Parser {
134134
// A non-empty cell?
135135
else if (token.type !== tt.eof && token.type !== tt.semi) {
136136

137-
// A destructuring cell, maybe?
138-
// (A parenthesized expression followed by the equals operator.)
137+
// A destructuring cell, or parenthesized expression? (A destructuring
138+
// cell is a parenthesized expression followed by the equals operator.)
139139
if (token.type === tt.parenL) {
140140
id = this.parseParenAndDistinguishExpression(true);
141141
if (this.eat(tt.eq)) {
@@ -168,7 +168,7 @@ export class CellParser extends Parser {
168168
}
169169
}
170170

171-
// A block or an expression?
171+
// A block or non-parenthesized expression?
172172
if (body === null) {
173173
body = token.type === tt.braceL
174174
? this.parseBlock()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(function foo() { return 42; })
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"type": "Cell",
3+
"start": 0,
4+
"end": 32,
5+
"id": {
6+
"type": "Identifier",
7+
"start": 10,
8+
"end": 13,
9+
"name": "foo"
10+
},
11+
"body": {
12+
"type": "FunctionExpression",
13+
"start": 1,
14+
"end": 30,
15+
"id": {
16+
"type": "Identifier",
17+
"start": 10,
18+
"end": 13,
19+
"name": "foo"
20+
},
21+
"expression": false,
22+
"generator": false,
23+
"async": false,
24+
"params": [],
25+
"body": {
26+
"type": "BlockStatement",
27+
"start": 16,
28+
"end": 30,
29+
"body": [
30+
{
31+
"type": "ReturnStatement",
32+
"start": 18,
33+
"end": 28,
34+
"argument": {
35+
"type": "Literal",
36+
"start": 25,
37+
"end": 27,
38+
"value": 42,
39+
"raw": "42"
40+
}
41+
}
42+
]
43+
}
44+
},
45+
"async": false,
46+
"generator": false,
47+
"references": [],
48+
"fileAttachments": [],
49+
"databaseClients": [],
50+
"secrets": []
51+
}

0 commit comments

Comments
 (0)