Google Closure Compiler 在 let 声明时用 JSC_CONSTANT_REASSIGNED_VALUE_ERROR 警告

Google Closure Compiler warns with JSC_CONSTANT_REASSIGNED_VALUE_ERROR on let declarations

我正在使用 Google Closure Compiler 来缩小以下代码:

{
  let x = 10,
      y = 20;
  console.log(y);
}

{
  let x = 30,
      y = 40;
  console.log(y);
}

(另请参阅 Closure Compiler Web 应用程序的 this link。)

令我莫名其妙的是,编译器给出了以下警告:

JSC_CONSTANT_REASSIGNED_VALUE_ERROR: constant y assigned a value more than once.
Original definition at Input_0:4 at line 10 character 6
      y = 40;
      ^

这引发了多个问题:

这是ES5语法的输出代码:

var x=10,y=20;console.log(y);var x[=14=]=30;y=40;console.log(y);

确实,Google Closure Compiler 重用了第一个块中的 y 变量。但是,它不会为 x 执行此操作。

知道这里发生了什么吗?

此问题已修复 https://github.com/google/closure-compiler/commit/b3146ab187540c5bdf3b24f8ebf6ddede7fd63c5

当前版本(或网络服务)不再可重现。