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

[Bug] do expression in generator function compiles wrong #12730

Closed
1 task
xialvjun opened this issue Feb 1, 2021 · 3 comments
Closed
1 task

[Bug] do expression in generator function compiles wrong #12730

xialvjun opened this issue Feb 1, 2021 · 3 comments
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Spec: Do Expressions

Comments

@xialvjun
Copy link

xialvjun commented Feb 1, 2021

Bug Report

  • I would like to work on a fix!

Current behavior

A B is ok, but C is wrong.

Input Code

function* C() {
  let p = yield 'asdasd';
  return m(
    'div',
    m('p', p),
    do {
      let b = yield 123;
      m('button', b)
    },
  );
}

Expected behavior

function* C() {
  let p = yield 'asdasd';
  return m('div', m('p', p), yield* function* () {
    let b = yield 123;
    return m('button', b);
  }());
}
  • Babel version(s): [e.g. v7.12.0]
  • Node/npm version: [e.g. Node 12/npm 7]
  • OS: [e.g. macOS 10.15.4, Windows 10]
  • Monorepo: [e.g. yes/no/Lerna]
  • How you are using Babel: [e.g. webpack, rollup, parcel, babel-register]
@babel-bot
Copy link
Collaborator

Hey @xialvjun! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@bakkot
Copy link
Contributor

bakkot commented Feb 1, 2021

Note that the code produced for C isn't even legal: it has a yield expression in a non-generator function. When there's a yield, you have to generate a generator and yield* it. (There's some discussion of this in this issue.)

@JLHwung
Copy link
Contributor

JLHwung commented Apr 6, 2021

Fixed in #10101

@JLHwung JLHwung closed this as completed Apr 6, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 7, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Spec: Do Expressions
Projects
None yet
Development

No branches or pull requests

5 participants