From 57bc9b1b0a09133b91e714e3605a9cc302da76e1 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 12 Mar 2015 23:11:33 +0100 Subject: [PATCH] Move parsing of yield into parseMaybeAssign Issue #219 --- acorn.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/acorn.js b/acorn.js index 65905a3703..c246fa8f37 100644 --- a/acorn.js +++ b/acorn.js @@ -2156,6 +2156,8 @@ // operators like `+=`. pp.parseMaybeAssign = function(noIn, refShorthandDefaultPos) { + if (this.type == tt._yield && this.inGenerator) return this.parseYield(); + var failOnShorthandAssign; if (!refShorthandDefaultPos) { refShorthandDefaultPos = {start: 0}; @@ -2310,7 +2312,7 @@ return this.finishNode(node, "ThisExpression"); case tt._yield: - if (this.inGenerator) return this.parseYield(); + if (this.inGenerator) unexpected(); case tt.name: var start = this.currentPos(); @@ -2844,7 +2846,7 @@ pp.parseYield = function() { var node = this.startNode(); this.next(); - if (this.eat(tt.semi) || this.insertSemicolon()) { + if (this.type == tt.semi || this.canInsertSemicolon()) { node.delegate = false; node.argument = null; } else {