Google闭包编译器不报告除零

Google closure compiler does not report divide-by-zero

本文关键字:报告 闭包 编译器 Google      更新时间:2023-09-26

我已经运行了google closure compiler for next:

alert(1 / 0);
与命令:

java -jar node_modules'google-closure-compiler'compiler.jar --warning_level=VERBOSE test.js 

,它不报告任何内容。我以为它说的是除以零,因为参考(https://developers.google.com/closure/compiler/docs/error-ref)提到了

JSC_DIVIDE_BY_0_ERROR:

除以0

此错误表示您使用了分母为0的算术除法表达式。在运行时除以零会产生运行时错误。

我还测试了JSC_BITWISE_OPERAND_OUT_OF_RANGE的示例代码:
var y = 1024 * 1024 * 1024 * 2 >> 2;

在这种情况下,Google闭包编译器准确地指出了问题。

test.js:2: WARNING - Operand out of range, bitwise operation will lose information: NUMBER 2.147483648E9 2 [length: 22] [source_file: test.js]
var y = 1024 * 1024 * 1024 * 2 >> 2;
        ^

如何获得JSC_DIVIDE_BY_0_ERROR的顶级源代码?

编译器源代码中已不存在JSC_DIVIDE_BY_0_ERROR错误,可在https://github.com/google/closure-compiler中查找。因此,错误检查必须被删除。

闭包编译器文档目前有点过时,分散在不同的页面中。