Closed
Description
My understanding is that the compiler should not remove globally visible assignment to properties at SIMPLE_OPTIMIZATION level. If that is true then there is a bug which can be triggered with this simple test case.
closure-compiler-global-properties.js
When compiled using current master (15049ed) the assignment to the global object will be removed, generating invalid output.
This is my command line
> java -jar closure-compiler-1.0-SNAPSHOT.jar --compilation_level SIMPLE_OPTIMIZATIONS --js closure-compiler-global-properties.js --js_output_file closure-compiler-global-properties.js.out
This is the expected result
> nodejs closure-compiler-global-properties.js
{ i0: 0, i1: 0 }
{ i0: 2, i1: 3 }
This is the result generated by the JS output of the compiler
> nodejs closure-compiler-global-properties.js.out
{ i0: 0, i1: 0 }
{ i0: 0, i1: 0 }
The bug may be connected to the DeadPropertyAssignmentElimination pass. If I disable the pass from DefaultPassConfig.java the generated output becomes correct again.