Search code examples
javascriptgoogle-closure-compilerdivide-by-zero

Google closure compiler does not report divide-by-zero


I have run google closure compiler for next:

alert(1 / 0);

with command:

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

and it does not report anything. I expected it says something about devide-by-zero because the reference(https://developers.google.com/closure/compiler/docs/error-ref) mentions about

JSC_DIVIDE_BY_0_ERROR:

Divide by 0

This error means that you an arithmetical division expression with a denominator of 0. Dividing by zero at runtime produces a runtime error.

I've also tested the example code for JSC_BITWISE_OPERAND_OUT_OF_RANGE:

var y = 1024 * 1024 * 1024 * 2 >> 2;

and in this case, google closure compiler exactly point out the problem.

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;
        ^

How can I get JSC_DIVIDE_BY_0_ERROR for the top source code?


Solution

  • The JSC_DIVIDE_BY_0_ERROR error no longer exists in the compiler source code, you can search for it at https://github.com/google/closure-compiler. So that error check must have been removed.

    The Closure Compiler documentation is currently a bit out of date and scattered among various pages.