summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/PrivateName/error-outside-class.js
blob: 8ddb380872fb43103c96ed739cd7b86adef2a656 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// Can't reference a private field without an object
assertThrowsInstanceOf(() => eval('#x'), SyntaxError);

// Can't reference a private field without an enclosing class
assertThrowsInstanceOf(() => eval('this.#x'), SyntaxError);

// Can't reference a private field in a random function outside a class context
assertThrowsInstanceOf(
    () => eval('function foo() { return this.#x'), SyntaxError);


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