Closed
Description
msgpack-lite wip branch's test fails when minified with Uglify 3.4.9.
It also passes when minified with Uglify 3.4.8 however.
It looks 3.4.9 breaks something about the order to execute.
JavaScript input
The following function is found at https://github.com/kawanet/msgpack-lite/blob/master/lib/buffer-lite.js
function write(string, offset) {
var buffer = this;
var index = offset || (offset |= 0);
var length = string.length;
var chr = 0;
var i = 0;
while (i < length) {
chr = string.charCodeAt(i++);
if (chr < 128) {
buffer[index++] = chr;
} else if (chr < 0x800) {
// 2 bytes
buffer[index++] = 0xC0 | (chr >>> 6);
buffer[index++] = 0x80 | (chr & 0x3F);
} else if (chr < 0xD800 || chr > 0xDFFF) {
// 3 bytes
buffer[index++] = 0xE0 | (chr >>> 12);
buffer[index++] = 0x80 | ((chr >>> 6) & 0x3F);
buffer[index++] = 0x80 | (chr & 0x3F);
} else {
// 4 bytes - surrogate pair
chr = (((chr - 0xD800) << 10) | (string.charCodeAt(i++) - 0xDC00)) + 0x10000;
buffer[index++] = 0xF0 | (chr >>> 18);
buffer[index++] = 0x80 | ((chr >>> 12) & 0x3F);
buffer[index++] = 0x80 | ((chr >>> 6) & 0x3F);
buffer[index++] = 0x80 | (chr & 0x3F);
}
}
return index - offset;
}
The uglifyjs
CLI command
uglifyjs -c -m -o min.js buffer-lite.js
Uglify 3.4.8 🆗
function write(r, t) {
for (var e = this, h = t || (t |= 0), n = r.length, o = 0, a = 0; a < n;)
(o = r.charCodeAt(a++)) < 128 ? e[h++] = o
: (o < 2048 ? e[h++] = 192 | o >>> 6
: (o < 55296 || 57343 < o ? e[h++] = 224 | o >>> 12
: (o = 65536 + (o - 55296 << 10 | r.charCodeAt(a++) - 56320), e[h++] = 240 | o >>> 18, e[h++] = 128 | o >>> 12 & 63), e[h++] = 128 | o >>> 6 & 63), e[h++] = 128 | 63 & o);
return h - t
}
Uglify 3.4.9 🆖
function write(r, t) {
for (var e = this, h = t || (t |= 0), n = r.length, o = 0, a = 0; a < n;)
o = r.charCodeAt(a++), e[h++] = o < 128 ? o
: (e[h++] = o < 2048 ? 192 | o >>> 6
: (e[h++] = o < 55296 || 57343 < o ? 224 | o >>> 12
: (o = 65536 + (o - 55296 << 10 | r.charCodeAt(a++) - 56320), e[h++] = 240 | o >>> 18, 128 | o >>> 12 & 63), 128 | o >>> 6 & 63), 128 | 63 & o);
return h - t
}
It looks e[h++] = o
is moved to wrong positions.
Metadata
Metadata
Assignees
Labels
No labels