Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Babel does not parenthesize yield expressions inside ternary conditional test #4632

Closed
bjouhier opened this issue Oct 1, 2016 · 0 comments · Fixed by #4633
Closed

Babel does not parenthesize yield expressions inside ternary conditional test #4632

bjouhier opened this issue Oct 1, 2016 · 0 comments · Fixed by #4633
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@bjouhier
Copy link
Contributor

bjouhier commented Oct 1, 2016

Bug found in babel 6.16.

Source:

function* foo() {
  return (yield 1) ? 2 : 3;
}
console.log(foo().next());

Transformed:

function* foo() {
  return yield 1 ? 2 : 3;
}
console.log(foo().next());

Parentheses around yield 1 have been dropped!

Steps to reproduce:

# save source as foo.js
$ node foo.js
{ value: 1, done: false } 
$ babel foo.js > bar.js
$ node bar.js
{ value: 2, done: false }

Fix was easy. I'm going to submit a PR.

bjouhier added a commit to bjouhier/babel that referenced this issue Oct 1, 2016
bjouhier added a commit to bjouhier/babel that referenced this issue Oct 1, 2016
@hzoo hzoo added the i: bug label Oct 1, 2016
@hzoo hzoo closed this as completed in #4633 Oct 1, 2016
hzoo pushed a commit that referenced this issue Oct 1, 2016
* fixed #4632 - missing parentheses around yield expression in conditional test

* #4632 - added test
panagosg7 pushed a commit to panagosg7/babel that referenced this issue Jan 17, 2017
…el#4633)

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

* babel#4632 - added test
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants