summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/stub-fold-closeiter.js
blob: 8e91d3737c41b04196221ff7b7340b085042c0b9 (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
class Iterator {
  val = 0;
  next() {
    return { value: this.val++, done: false }
  }
  return() { return { value: undefined, done: true }}
}

var arr = [];
for (var i = 0; i < 10; i++) {
  class SubIter extends Iterator {}
  var iterable = {
    [Symbol.iterator]() { return new SubIter(); }
  }
  arr.push(iterable);
}

function foo() {
  for (var x of arr[i % arr.length]) {
    if (x > 1) { return; }
  }
}

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