summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/PrivateName/nested-class-name-used.js
blob: cc1a77f375bfe4edf8d46e829deb6c88fb1b2f8f (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
// |reftest| shell-option(--enable-private-fields) skip-if(!xulRuntime.shell) -- requires shell-options

// AllPrivateIdentifiersValid uses only lexical string names, not
// the dynamic private names; which means the below is not a syntax
// error but is instead a TypeError on access.

class A {
  #x = 10;
  f() {
    class B {
      g() {
        return this.#x;  // note: #x isn't declared in this class, but
                         // the enclosing.
      }
    };
    this.y = new B;
  }
  constructor() {
    this.f();
  }
  g() {
    return this.y.g();
  }
};

a = new A;
try {
  a.g();
} catch (e) {
  assertEq(e instanceof TypeError, true);
}

if (typeof reportCompare === 'function') reportCompare(0, 0);