summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/bug1773496.js
blob: 91ec0b4c8c4d95e474b11aacbf13a288684437e3 (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
47
var shouldBail = false;
function foo() {
  if (shouldBail) {
    bailout();
    return 0;
  }
  for (var i = 0; i < 1000; i++) {}
  return { value: undefined, done: true }
}

const iterable = {
  [Symbol.iterator]() {
    return {
      i: 0,
      next() {
        return { value: this.i++, done: false }
      },
      return() {
        return foo();
      }
    };
  }
}

function closeIter() {
  with ({}) {}
  for (var x of iterable) {
    if (x == 2) {
      break;
    }
  }
}

with ({}) {}
for (var i = 0; i < 100; i++) {
  closeIter();
}

shouldBail = true;

caught = false;
try {
  closeIter();
} catch {
  caught = true;
}
assertEq(caught, true);