Closed
Description
From @stephan-gruen on September 12, 2017 13:0
I ran into this while testing out the BZip2Encoder class from the widely used archive library, which does not work if minified.
At the end of the day this is why: the shift result from unminified and minified JavaScript is not the same if the value is negativ. So this is bad as the behavior should be the same.
print('1 >> 0 = ${1 >> 0}');
print('0 >> 0 = ${0 >> 0}');
print('-1 >> 0 = ${-1 >> 0}');
print('-2 >> 0 = ${-2 >> 0}');
print('1 >> 1 = ${1 >> 1}');
print('0 >> 1 = ${0 >> 1}');
print('-1 >> 1 = ${-1 >> 1}');
print('-2 >> 1 = ${-2 >> 1}');
print('1 << 0 = ${1 << 0}');
print('0 << 0 = ${0 << 0}');
print('-1 << 0 = ${-1 << 0}');
print('-2 << 0 = ${-2 << 0}');
print('1 << 1 = ${1 << 1}');
print('0 << 1 = ${0 << 1}');
print('-1 << 1 = ${-1 << 1}');
print('-2 << 1 = ${-2 << 1}');
pub build mode Debug (uses dart2js to generate unminified JavaScript):
1 >> 0 = 1
0 >> 0 = 0
-1 >> 0 = -1
-2 >> 0 = -2
1 >> 1 = 0
0 >> 1 = 0
-1 >> 1 = -1
-2 >> 1 = -1
1 << 0 = 1
0 << 0 = 0
-1 << 0 = -1
-2 << 0 = -2
1 << 1 = 2
0 << 1 = 0
-1 << 1 = -2
-2 << 1 = -4
pub build mode Release (uses dart2js to generate minified JavaScript):
1 >> 0 = 1
0 >> 0 = 0
-1 >> 0 = 4294967295
-2 >> 0 = 4294967294
1 >> 1 = 0
0 >> 1 = 0
-1 >> 1 = 4294967295
-2 >> 1 = 4294967295
1 << 0 = 1
0 << 0 = 0
-1 << 0 = 4294967295
-2 << 0 = 4294967294
1 << 1 = 2
0 << 1 = 0
-1 << 1 = 4294967294
-2 << 1 = 4294967292
Copied from original issue: dart-lang/pub#1703