javascript - Google Closure Compiler: remove dead code by setting CompilerOptions -


i trying configure compileroptions of google closure compiler setting corresponding fields. however, when call method setremovedeadcode() activate dead code removal in simple mode, warning "unreachable code" reported , dead code not removed. why that?

the code following:

if (false) console.log(x);  //dead code should removed 

what activate setremovedeadcode() @ end of method createoptions(), deactivate other options. doing same thing on other options setcoalescevariablenames() works fine. insights appreciated.

the removedeadcode option triggers pass looks @ side-effects , control-flow-graph. can see looking @ unit tests:

https://github.com/google/closure-compiler/blob/a1488d59c11fd535ded79d37c11cd418927782ce/test/com/google/javascript/jscomp/unreachablecodeeliminationtest.java

it doesn't constant values. there option however, "fold constants" (via setfoldconstants) remove if constant condition.


Comments