Skip to content

Conversation

@matthiasblaesing
Copy link
Contributor

The JS parser should invalid constructs such as:

  • Multiple declarations of constructor:
      class T {
          constructor() {}
          constructor() {}
      }
  • Private constructors:
      class T {
          #constructor() {}
      }
  • Fields that are named constructor:
      class T {
          constructor = X
      }
  • Generators named constructor:
      class T {
          *constructor() {}
      }
  • Accessors named constructor:
      class S {
          get constructor() {}
      }
    
      class T {
          set constructor(value) {}
      }

Private element must be declared only once:

  • Accessor pair should be accepted
      class T {
          get #X() {};
          set #X(value) {};
      }
  • Reject plain field and and accessor
      class T {
          #X = 1;
          get #X() {};
      }
      class T {
          #X = 1;
          set #X() {};
      }
  • Plain field and method should be rejected
      class T {
          #X;
          #X() {};
      }
  • Duplicate method should be rejected
      class T {
          #X() {};
          #X() {};
      }
  • Duplicate fields should be rejected
      class T {
          #X;
          #X;
      }
  • Mixed static declarations should be rejected
      class T {
          get #X() {};
          static set #X(value) {};
      }

Closes: #8953

@matthiasblaesing matthiasblaesing added this to the NB29 milestone Nov 20, 2025
@matthiasblaesing matthiasblaesing added JavaScript [ci] enable web job and extra JavaScript tests (webcommon/javascript2.editor) ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Nov 20, 2025
@matthiasblaesing
Copy link
Contributor Author

Unless I get objects, I'll merge early next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) JavaScript [ci] enable web job and extra JavaScript tests (webcommon/javascript2.editor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Javascript private class variables error check

1 participant