I found an issue with "simple" compression and binary "or" operations. In this case, the variable is just overwritten with "48" instead of doing clean "or" operations on given input.
With advanced compression (or just whitespace removal) I get valid code.
var addFlags = function(data) {
data.flags = (data.flags |= 8) | 4
data.flags = (data.flags |= 16) | 32
}
var data = {flags:1};
addFlags(data)
console.log(data.flags); // expected: 61
var addFlags = function(a) {
a.flags = 12;
a.flags = 48;
}, data = {flags:1};
addFlags(data);
console.log(data.flags);
var addFlags = function(a) {
a.flags |= 12;
a.flags |= 48;
};
var b = {flags:1};
addFlags(b);
console.log(b.flags);
I found an issue with "simple" compression and binary "or" operations. In this case, the variable is just overwritten with "48" instead of doing clean "or" operations on given input.
With advanced compression (or just whitespace removal) I get valid code.
Input code: (generated by https://github.com/openfl/lime convertor)
Output in SIMPLE_OPTIMIZATIONS
-> output 48 👎
Output in ADVANCED_OPTIMIZATIONS
-> output: 61 👍
Playground: https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520SIMPLE_OPTIMIZATIONS%250A%252F%252F%2520%2540formatting%2520pretty_print%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250Avar%2520addFlags%2520%253D%2520function(data)%2520%257B%250A%2520%2520%2520%2520data.flags%2520%253D%2520(data.flags%2520%257C%253D%25208)%2520%257C%25204%250A%2520%2520%2520%2520data.flags%2520%253D%2520(data.flags%2520%257C%253D%252016)%2520%257C%252032%250A%257D%250A%250Avar%2520data%2520%253D%2520%257Bflags%253A1%257D%253B%250AaddFlags(data)%250Aconsole.log(data.flags)%253B