summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/bug1273858-2.js
blob: 6d274cf02b9545fc2aba2dbdfeaee4592a8f2e89 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
// |jit-test| --no-threads

function t1() {
    let x = [];

    try
    {
        for (let k = 0; k < 100; ++k)
        {
            let w = () => k; // Lexical capture

            if (w() > 10)
            {
                throw () => w; // Lexical capture
            }

            x[k] = w;
        }
    }
    catch (e)
    {
        // 'w' and 'k' should leave scope as exception unwinds

        try {
            eval("k");
            throw false;
        }
        catch (e) {
            if (!(e instanceof ReferenceError))
                throw "Loop index escaped block";
        }

        try {
            eval("w");
            throw false;
        }
        catch (e) {
            if (!(e instanceof ReferenceError))
                throw "Local name escaped block";
        }
    }
}
t1();
t1();
t1();
t1();