Current behavior
Using REPL (current/default v7.11.1) with all of checkboxes disabled:
(Explicitly disable ENV or enable es2015 to see the error via the link above)
Input Code
function f(y){
for(let x of y){
let x = y;
return x;
}
}
Expected behavior
That should successfully compile just as this code does:
function f(z){
for(let x=0; x<y; x++){
let x = y;
return x;
}
}
Which gives
"use strict";
function f(z) {
for (var x = 0; x < y; x++) {
var _x = y;
return _x;
}
}
Actual behavior
However, the error is:
/repl.js: Duplicate declaration "x"
1 | function f(y){
2 | for(let x of y){
> 3 | let x = y;
| ^
4 | return x;
5 | }
6 | }
Additional context
If the ES6 transpiling (let to var) is disabled (ENV: firefox 74), that code correctly gives:
"use strict";
function f(y) {
for (let x of y) {
let x = y;
return x;
}
}
Environment
- Babel version: REPL v7.11.1
- Browser: Firefox 76 on Windows 7
Current behavior
Using REPL (current/default v7.11.1) with all of checkboxes disabled:
(Explicitly disable
ENVor enablees2015to see the error via the link above)Input Code
Expected behavior
That should successfully compile just as this code does:
Which gives
Actual behavior
However, the error is:
Additional context
If the ES6 transpiling (
lettovar) is disabled (ENV:firefox 74), that code correctly gives:Environment