for (let i = 0; i < 5; i++) {
console.log(i++, [2].every(x => x != i))
continue
}
Bublé creates this:
var loop = function ( i$1 ) {
console.log(i$1++, [2].every(function (x) { return x != i$1; }))
return
};
for (var i = 0; i < 5; i++) loop( i );
It'd normally add an i = i$1 to the end of the function, because it noticed that i$1 is mutated, but for some reason it doesn't do that when the end of the loop isn't reachable. I originally observed a case where the assignment was generated, but not reached because of a continue (compiled to a return).
In any case, this generated code produces different output than the original, because the mutations to i are dropped at the end of the loop body.
For this code...
Bublé creates this:
It'd normally add an
i = i$1
to the end of the function, because it noticed thati$1
is mutated, but for some reason it doesn't do that when the end of the loop isn't reachable. I originally observed a case where the assignment was generated, but not reached because of acontinue
(compiled to areturn
).In any case, this generated code produces different output than the original, because the mutations to
i
are dropped at the end of the loop body.