Skip to content

Commit 64e7322

Browse files
committed
Merge pull request #135 from eslint/issue134
Fix: Allow yield without value as function param (fixes #134)
2 parents 72d0a8e + d56a2b1 commit 64e7322

File tree

3 files changed

+152
-1
lines changed

3 files changed

+152
-1
lines changed

espree.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4654,7 +4654,7 @@ function parseYieldExpression() {
46544654
return markerApply(marker, astNodeFactory.createYieldExpression(null, delegateFlag));
46554655
}
46564656

4657-
if (!match(";")) {
4657+
if (!match(";") && !match(")")) {
46584658
if (!match("}") && lookahead.type !== Token.EOF) {
46594659
expr = parseAssignmentExpression();
46604660
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
module.exports = {
2+
"type": "Program",
3+
"body": [
4+
{
5+
"type": "ExpressionStatement",
6+
"expression": {
7+
"type": "FunctionExpression",
8+
"id": null,
9+
"params": [],
10+
"body": {
11+
"type": "BlockStatement",
12+
"body": [
13+
{
14+
"type": "ExpressionStatement",
15+
"expression": {
16+
"type": "CallExpression",
17+
"callee": {
18+
"type": "Identifier",
19+
"name": "fn",
20+
"range": [
21+
16,
22+
18
23+
],
24+
"loc": {
25+
"start": {
26+
"line": 1,
27+
"column": 16
28+
},
29+
"end": {
30+
"line": 1,
31+
"column": 18
32+
}
33+
}
34+
},
35+
"arguments": [
36+
{
37+
"type": "YieldExpression",
38+
"argument": null,
39+
"delegate": false,
40+
"range": [
41+
19,
42+
24
43+
],
44+
"loc": {
45+
"start": {
46+
"line": 1,
47+
"column": 19
48+
},
49+
"end": {
50+
"line": 1,
51+
"column": 24
52+
}
53+
}
54+
}
55+
],
56+
"range": [
57+
16,
58+
25
59+
],
60+
"loc": {
61+
"start": {
62+
"line": 1,
63+
"column": 16
64+
},
65+
"end": {
66+
"line": 1,
67+
"column": 25
68+
}
69+
}
70+
},
71+
"range": [
72+
16,
73+
26
74+
],
75+
"loc": {
76+
"start": {
77+
"line": 1,
78+
"column": 16
79+
},
80+
"end": {
81+
"line": 1,
82+
"column": 26
83+
}
84+
}
85+
}
86+
],
87+
"range": [
88+
14,
89+
28
90+
],
91+
"loc": {
92+
"start": {
93+
"line": 1,
94+
"column": 14
95+
},
96+
"end": {
97+
"line": 1,
98+
"column": 28
99+
}
100+
}
101+
},
102+
"generator": true,
103+
"expression": false,
104+
"range": [
105+
1,
106+
28
107+
],
108+
"loc": {
109+
"start": {
110+
"line": 1,
111+
"column": 1
112+
},
113+
"end": {
114+
"line": 1,
115+
"column": 28
116+
}
117+
}
118+
},
119+
"range": [
120+
0,
121+
30
122+
],
123+
"loc": {
124+
"start": {
125+
"line": 1,
126+
"column": 0
127+
},
128+
"end": {
129+
"line": 1,
130+
"column": 30
131+
}
132+
}
133+
}
134+
],
135+
"sourceType": "script",
136+
"range": [
137+
0,
138+
30
139+
],
140+
"loc": {
141+
"start": {
142+
"line": 1,
143+
"column": 0
144+
},
145+
"end": {
146+
"line": 1,
147+
"column": 30
148+
}
149+
}
150+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(function* () { fn(yield); });

0 commit comments

Comments
 (0)