Closed
Description
This only repros with SIMPLE_OPTIMIZATIONS. Advanced generates code that behaves as expected.
Repro:
// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level SIMPLE_OPTIMIZATIONS
// @formatting pretty_print
// ==/ClosureCompiler==
var flags = {internal: false};
/** @constructor */
var checkFlag = function() {
if(!flags.internal ) {
throw ("Error: flags.internal is " + flags.internal + "!");
}
};
var getCheckFlag = function() {
flags.internal = true;
var cf = new checkFlag();
// flags.checkFlag = checkFlag(); // works
flags.internal = false;
return cf;
};
var myCheckFlag = getCheckFlag();
Output:
var flags = {internal:!1}, checkFlag = function() {
if (!flags.internal) {
throw "Error: flags.internal is " + flags.internal + "!";
}
}, getCheckFlag = function() {
var a = new checkFlag;
flags.internal = !1;
return a;
}, myCheckFlag = getCheckFlag();
checkFlag()
throws because there is no flags.internal = !0;
before var a = new checkFlag;
.
Possibly related to #2874 ?
Metadata
Metadata
Assignees
Labels
No labels