Skip to content

Yield and await in class methods keys #8300

@nicolo-ribaudo

Description

@nicolo-ribaudo

Bug Report

Current Behavior
Babel generates invalid code (yield or await inside a normal function)

Input Code

  • REPL or Repo link if applicable:
function* f() {
  return class A {
    [yield 0]() {
      return 3;
    }
  }
}

var buildClass = f();
buildClass.next();
var A = buildClass.next("foo").value;
alert(new A().foo());

Expected behavior/code
It should alert 3

Babel Configuration (.babelrc, package.json, cli command)

preset-env

Environment

  • Babel version(s): v7.0.0-beta.52

Possible Solution
a) Compute the keys before the IIFE
b) Make the iife the correct function type

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Spec: ClassesoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions