Closed
Description
TypeScript Version: 2.1.4
Code
function baz(x: any) {
return [[x, x]];
}
function foo(set: any) {
for (const [value, i] of baz(set.values)) {
const bar: any = [];
(() => bar);
set.values.push(...[]);
}
};
Expected behavior:
Names of hidden/implementation variables should not clash.
Actual behavior:
Two _a
hidden variables are created which would be in different scopes under ES6 let
/const
but are in the same scope since they are var
:
function baz(x) {
return [[x, x]];
}
function foo(set) {
var _loop_1 = function (value, i) {
var bar = [];
(function () { return bar; });
(_a = set.values).push.apply(_a, []);
};
for (var _i = 0, _a = baz(set.values); _i < _a.length; _i++) {
var _b = _a[_i], value = _b[0], i = _b[1];
_loop_1(value, i);
}
var _a;
}
;
Note:
After pruning my code to isolate the issue, I'm not sure what the impact of the collision is anymore, but in my original code I was getting an infinite loop due to the loop index being part of the collision. I should be able to produce a short example like that if needed.