Skip to content

Commit

Permalink
Merge pull request #169 from eslint/issue165
Browse files Browse the repository at this point in the history
Fix: Yield as identifier in arrow func args (fixes #165)
  • Loading branch information
nzakas committed Jul 16, 2015
2 parents adf2775 + 725e9f9 commit 5880b41
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 0 deletions.
11 changes: 11 additions & 0 deletions espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -3321,6 +3321,17 @@ function reinterpretAsCoverFormalsList(expressions) {
param.type = astNodeTypes.AssignmentPattern;
delete param.operator;

if (param.right.type === astNodeTypes.YieldExpression) {
if (param.right.argument) {
throwUnexpected(lookahead);
}

param.right.type = astNodeTypes.Identifier;
param.right.name = "yield";
delete param.right.argument;
delete param.right.delegate;
}

params.push(param);
validateParam(options, param.left, param.left.name);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
defaultParams: true,
arrowFunctions: true,
generators: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
module.exports = {
"type": "Program",
"body": [
{
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "g",
"range": [
10,
11
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
}
},
"params": [],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "AssignmentPattern",
"left": {
"type": "Identifier",
"name": "x",
"range": [
17,
18
],
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 18
}
}
},
"right": {
"type": "Identifier",
"name": "yield",
"range": [
21,
26
],
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 26
}
}
},
"range": [
17,
26
],
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 26
}
}
}
],
"body": {
"type": "BlockStatement",
"body": [],
"range": [
31,
33
],
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 33
}
}
},
"generator": false,
"expression": false,
"range": [
16,
33
],
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 33
}
}
},
"range": [
16,
34
],
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 34
}
}
}
],
"range": [
14,
35
],
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 35
}
}
},
"generator": true,
"expression": false,
"range": [
0,
35
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
}
}
],
"sourceType": "script",
"range": [
0,
35
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function *g() { (x = yield) => {} }

0 comments on commit 5880b41

Please sign in to comment.