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

The FieldDefinition production incorrectly passes along Yield and Await to Initializer #2437

Open
rbuckton opened this issue Jun 17, 2021 · 0 comments
Labels

Comments

@rbuckton
Copy link
Contributor

Per the current spec:

image

This passes along the Yield and Await parameters to Initializer, which seems incorrect. A class field is wrapped in an implicit function, per https://tc39.es/ecma262/#sec-runtime-semantics-classfielddefinitionevaluation, step 3.e:

image

So a YieldExpression and AwaitExpression should not be valid in a class initializer.

Here is an example to illustrate the issue:

async function f(p) {
  return class C {
    x = await p; // when could this possibly be awaited?
  };
}
let C = await f(Promise.resolve(1));
let obj = new C();
obj.x; // what is this value?

It seems to me that Initializer[+In, ?Yield, ?Await] should be Initializer[+In, ~Yield, ~Await].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants