closure-compiler
closure-compiler copied to clipboard
"let" within switch causes variable reference error with outer let
function foo() {
let c = 3;
switch (c) {
case 4:
let c = 5;
break;
}
}
Expected: should be accepted
Actual: JSC_REFERENCE_BEFORE_DECLARE_ERROR: Illegal variable reference before declaration: c at line 3 character 10 switch (c) { ^
Compiler link:
https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520SIMPLE_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%250Afunction%2520foo()%2520%257B%250A%2520%2520let%2520c%2520%253D%25203%253B%250A%2520%2520switch%2520(c)%2520%257B%250A%2520%2520%2520%2520case%25204%253A%250A%2520%2520%2520%2520%2520%2520let%2520c%2520%253D%25205%253B%250A%2520%2520%2520%2520%2520%2520break%253B%250A%2520%2520%257D%250A%257D