summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/expressions/optional-chain-tdz.js
blob: e12d0fb860a56571f70a5612d466a8d4addd5a84 (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
// Test TDZ for optional chaining.

// TDZ for lexical |let| bindings with optional chaining.
{
  assertThrowsInstanceOf(() => {
    const Null = null;
    Null?.[b];
    b = 0;
    let b;
  }, ReferenceError);

  assertThrowsInstanceOf(() => {
    const Null = null;
    Null?.[b]();
    b = 0;
    let b;
  }, ReferenceError);

  assertThrowsInstanceOf(() => {
    const Null = null;
    delete Null?.[b];
    b = 0;
    let b;
  }, ReferenceError);
}

if (typeof reportCompare === "function")
  reportCompare(true, true);