closure-compiler
closure-compiler copied to clipboard
Variable inlining changes program behavior by ignoring var hoisting
test.js:
var x = 1;
var z = function () {
var y = x;
var x = 0;
return y;
}();
console.log(z);
Observed behavior:
$ node test.js
undefined
$ closure-compiler test.js
var x=1,z=function(){return 0}();console.log(z);
$ closure-compiler test.js | node
0
Desired behavior: closure-compiler should not change program behavior.
Version:
$ closure-compiler --version
Closure Compiler (http://github.com/google/closure-compiler)
Version: 1.0-SNAPSHOT
Built on: 2018-07-18 15:08