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

Add support for class static block #43092

Closed
wants to merge 83 commits into from

Conversation

Kingwl
Copy link
Contributor

@Kingwl Kingwl commented Mar 5, 2021

Fixes #43012

  • type definitions
  • factory
  • parser
  • binder
  • checker
    • grammar
    • use before assignment
  • transformer
  • emitter
  • visitor
  • tests

dragomirtitian and others added 30 commits February 3, 2021 18:44
…ing except classes.

Changes objects literal checking to not bail on first private name found in object literal.
Signed-off-by: Kubilay Kahveci <[email protected]>
Signed-off-by: Kubilay Kahveci <[email protected]>
Signed-off-by: Kubilay Kahveci <[email protected]>
Private methods inside class expressions should not error.

Signed-off-by: Kubilay Kahveci <[email protected]>
Signed-off-by: Kubilay Kahveci <[email protected]>
Signed-off-by: Kubilay Kahveci <[email protected]>
Signed-off-by: Kubilay Kahveci <[email protected]>
Signed-off-by: Kubilay Kahveci <[email protected]>
Signed-off-by: Kubilay Kahveci <[email protected]>
Signed-off-by: Kubilay Kahveci <[email protected]>
Signed-off-by: Kubilay Kahveci <[email protected]>
@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 8, 2021

dragomirtitian and others added 17 commits March 8, 2021 15:23
…lds-methods-and-accessors' into es-private-methods-and-accessors
…lds-methods-and-accessors' into es-private-methods-and-accessors
… and modified the existing helpers for get and set fields to do the same job.
…-accessors-simplify-emit

Es private methods and accessors simplify emit
@rbuckton
Copy link
Member

Well.... I think this one is depends on #42986 too....

Correction: This will depend on #42458, which includes everything in #42986.

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 18, 2021

Still confused with the boundary.

@rbuckton
Copy link
Member

I'm still reviewing #42458, and we've been discussing the fact that this in static fields is currently disallowed, which would effect the order of emit. Also, the static block proposal itself is layered on the static features and class private proposal, so its important that evaluation order is correct:

class C {
  static #x;
  static {
    this.#x; // ok
    this.#y; // error, #y not yet initialized
  }
  static #y;
  static {
    this.#x; // ok
    this.#y; // ok
  }
}

Either way, I'll still be happy to review when you think this is ready.

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 18, 2021

Okay, thanks a lot.

BTW, there's another PR to allow this in static context.

Actually, I'm confused with the function boundary in the specification(as i said in class static block repo).

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 18, 2021

tc39/proposal-class-static-block#27

This one.( Sorry I'm on mobile phone )

@rbuckton
Copy link
Member

I addressed your comment in that issue. The TL;DR is this:

  • Class bodies are not function boundaries (ClassHeritage and ComputedPropertyName are evaluated in the class's containing scope), so an await in either position in a class static block would be an error.
  • FormalParameters, ArrowFormalParameters, and AsyncArrowBindingIdentifier are function boundaries, since parameter initializers are evaluated when the function is called.
  • FunctionBody, GeneratorBody, AsyncGeneratorBody, AsyncFunctionBody, ConciseBody, and AsyncConciseBody are function boundaries.
  • A ClassStaticBlock is a function boundary, but is also a class static block (so await as an identifier would be an error).
  • Static/instance field initializers are function boundaries, as an implicit function is created that wraps the initializer to provide the correct this binding and access the lexical class binding.

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 19, 2021

I think I'd better to work based #42458. Even It's not been merged.

@Kingwl
Copy link
Contributor Author

Kingwl commented Mar 19, 2021

Close for #43308.

@Kingwl Kingwl closed this Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal class static block
5 participants