Skip to content

Commit

Permalink
fixed babel#4632 - missing parentheses around yield expression … (bab…
Browse files Browse the repository at this point in the history
…el#4633)

* fixed babel#4632 - missing parentheses around yield expression in conditional test

* babel#4632 - added test
  • Loading branch information
bjouhier authored and panagosg7 committed Jan 17, 2017
1 parent 6b0358e commit f5e73ef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/babel-generator/src/node/parentheses.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ export function YieldExpression(node: Object, parent: Object): boolean {
t.isUnaryLike(parent) ||
t.isCallExpression(parent) ||
t.isMemberExpression(parent) ||
t.isNewExpression(parent);
t.isNewExpression(parent) ||
(t.isConditionalExpression(parent) && node === parent.test);

}

export { YieldExpression as AwaitExpression };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function* asdf() {
(yield 1) || (yield 2);
(yield b)();
new (yield b)();
true ? (yield 1) : (yield 2);
(yield 1) ? (yield 2) : (yield 3);
yield (yield 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function* asdf() {
(yield 1) || (yield 2);
(yield b)();
new (yield b)();
true ? yield 1 : yield 2;
(yield 1) ? yield 2 : yield 3;
yield yield 1;
}

Expand Down

0 comments on commit f5e73ef

Please sign in to comment.