Closed peter-ahe-google closed 8 years ago
Proposed fix in CL 520497013.
Fixed by 34036c5aac323fe251db558ab9986eaa06408602.
The fix wasn't correct.
@asgerf has made a test that demonstrates why.
The problem is that other initializers can capture previously defined loop variables, and that updates can also capture loop variables. For example:
var closure;
for (var i=0, fn = () => i; i < 3; i++) {
i += 1;
closure = fn;
}
Expect.equals(1, closure());
Fixed by 6b464934860f5898ea71285306096ff60bad4563.
Closure conversion needs to support capturing the for-loop variable and pay special attention to the fact that a new variable is introduced per iteration.