Skip to content

Static fields named "constructor" should be a parser error #10459

@nicolo-ribaudo

Description

@nicolo-ribaudo

Bug Report

Expected Behavior
Static class fields can't be named constructor. We already disable it for instance fields.

Input Code

  • REPL or Repo link if applicable:
class A {
  static constructor;
}

repl

Specification: https://tc39.es/proposal-static-class-features/#sec-static-semantics-early-errors


If anyone wants to work on this issue, please leave a comment below! If you need any help, plase ask me (or to any other Babel team member) on Slack 🙂

If you don't know how to clone Babel, follow these steps: (you need to have make and yarn available on your machine).

  1. Fork the repo
  2. Run git clone https://github.com/<YOUR_USERNAME>/babel.git && cd babel
  3. Run yarn && make bootstrap
  4. Wait ⏳
  5. Run make watch (or make build whenever you change a file)
  6. Add a test in packages/babel-parser/test/fixtures/experimental/class-properties (you can take the no-ctor test in the same folder as an example)
  7. Update the code!
  8. yarn jest parser to run the tests
  9. If it is working, run make test to run all the tests
  10. Note: this change will likely also impact the results of running the Test262 suite on Babel.
    • Before running those tests you need to run make bootstrap-test262 to download them
    • Use make test-test262 to run them
    • If some tests which were previously failing now pass, you can run make test-test262-update-whitelist
  11. Run git push and open a PR!

Tip: if you don't know where to start from, try to Ctrl+F for the error generated by non-static fields named constructor! 😄

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions