summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/elements/private-static-method-not-writable.js
blob: ce0d1f9cd18c16c8b2a918b175fdfd9068cd96bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (C) 2021 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: >
  Throws TypeError when attempting to overwrite a private static method.
esid: sec-privateset
info: |
  7.3.30 PrivateSet ( P, O, value )
  1. Let entry be ! PrivateElementFind(P, O).
  2. If entry is empty, throw a TypeError exception.
  3. If entry.[[Kind]] is field, then
    ...
  4. Else if entry.[[Kind]] is method, then
    a. Throw a TypeError exception.
  5. ...

features: [class, class-static-methods-private]
---*/

class C {
  static #m() {}

  static assign() {
    this.#m = 0;
  }
}

assert.throws(TypeError, function() {
  C.assign();
});

reportCompare(0, 0);