Skip to content

Commit

Permalink
Updates to yield delegation linting. Fixes jshintgh-1544
Browse files Browse the repository at this point in the history
  • Loading branch information
wingo authored and rwaldron committed Nov 3, 2014
1 parent b5dd259 commit aad9062
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4218,8 +4218,15 @@ var JSHINT = (function () {
warning("W104", state.tokens.curr, "yield");
}
funct["(generator)"] = "yielded";
var delegatingYield = false;
if (state.option.inESNext() && peek() == "*") {
delegatingYield = true;
advance("*");
}
if (this.line === state.tokens.next.line || !state.option.inMoz(true)) {
if (state.tokens.next.id !== ";" && !state.tokens.next.reach && state.tokens.next.nud) {
if (delegatingYield ||
(state.tokens.next.id !== ";" && !state.tokens.next.reach && state.tokens.next.nud)) {

nobreaknonadjacent(state.tokens.curr, state.tokens.next);
this.first = expression(10);

Expand Down
1 change: 1 addition & 0 deletions tests/unit/fixtures/yield-expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ function* G() {
yield ? yield : yield;
yield ? yield ? yield : yield : yield;
yield ? yield ? yield : yield : yield ? yield : yield;
yield* (function*(){})();
}

0 comments on commit aad9062

Please sign in to comment.