CC incorrectly merges uninitialised let in a for loop body into an outer var in

Author: copyCreated Oct 1, 2026Updated Oct 1, 2026
% cat repro.js 
var n = 2;
function f() {
    var y;
    while (n--) {
        let x;
        console.log(x);
        x = n;
    }
    y = Math.random();
    return y + y;
}
f();
% java -jar compiler.jar -O SIMPLE --language_out ECMASCRIPT_2020 --js repro.js --js_output_file out.js
[...]
% node repro.js 
undefined
undefined
% node out.js 
undefined
1
% cat out.js 
var n=2;function f(){for(var a;n--;)console.log(a),a=n;a=Math.random();return a+a}f();

Reference: https://github.com/copy/v86/issues/1640