Skip to content

Private methods will be overwritten #1424

@2z6c

Description

@2z6c

Building the class which has a static field and two or more private methods, private methods will be overwritten by the last one.

class T {
  #a() { return 'a'; }
  #b() { return 'b'; }
  static c;
  d() { console.log(this.#a()); }
}

The d() is expected to return 'a', but it returns 'b'.
Here is the output code

...
  var _a, __create, _b, __create;
...
  _a = new WeakSet();
  __create = function() {
    return "a";
  };
  _b = new WeakSet();
  __create = function() {
    return "b";
  };
...

__create is declared twice, and the first __create is overwritten by the next one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions