You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In two words: float numbers not pushed into array if in push function shift is called.
Version: 8.5.0
Platform: linux x86_64
classFixedArrayextendsArray{constructor(length){super(length);this.maxLength=length;}push(...args){console.log('what to push',args);super.push.apply(this,args);console.log('array after push',this);if(this.length>this.maxLength){console.log('what is shifted?',super.shift.apply(this));}}}varddd=newFixedArray(30);ddd.push(1);ddd.push(2);ddd.push(3);ddd.push(0.4);ddd.push(0.5);ddd.push(0.6);console.log(ddd);
Result:
what to push [ 1 ]
array after push FixedArray [ <30 empty items>, 1, maxLength: 30 ]
what is shifted? undefined
what to push [ 2 ]
array after push FixedArray [ <29 empty items>, 1, 2, maxLength: 30 ]
what is shifted? undefined
what to push [ 3 ]
array after push FixedArray [ <28 empty items>, 1, 2, 3, maxLength: 30 ]
what is shifted? undefined
what to push [ 0.4 ]
array after push FixedArray [ <27 empty items>, 1, 2, 3, 0.4, maxLength: 30 ]
what is shifted? undefined
what to push [ 0.5 ]
array after push FixedArray [ <27 empty items>, 1, 2, 3, 0.5, maxLength: 30 ]
what is shifted? undefined
what to push [ 0.6 ]
array after push FixedArray [ <27 empty items>, 1, 2, 3, 0.6, maxLength: 30 ]
what is shifted? undefined
FixedArray [ <27 empty items>, 1, 2, 3, maxLength: 30 ]
Here's the code that stopped working in 8.5.0, but it was working in 8.4.0.
There's a class FixedArray that basically overrides push method. When I try to push float value into such array it pushes only once, however it should be pushed every second.
Another strange thing is if you change it to ddd.push(5); it works normally and integer value is pushed into this array every second.
If you remove shift() from a push, then all works also normally.
PS: In chrome versions from 60 to 63 all works normally.
Activity
vsemozhetbyt commentedon Sep 15, 2017
Simplified case:
targos commentedon Sep 15, 2017
This is fixed in V8 6.1.
targos commentedon Sep 15, 2017
/cc @nodejs/v8
SkeLLLa commentedon Sep 15, 2017
@targos then this is related to #15393
vsemozhetbyt commentedon Sep 15, 2017
Even more simplified case:
[ <2 empty items> ]So the issue is:
Array.prototype.shift()skips empty slots till the first float number and shifts this number instead?SkeLLLa commentedon Sep 15, 2017
@vsemozhetbyt I don't think so, because is you look into my example there were some integers before floats and they were not shifted. Also:
vsemozhetbyt commentedon Sep 15, 2017
Yes, it seems for arrays with an initial hole and a non-SMI number,
Array.prototype.shift()becomesArray.prototype.pop().targos commentedon Sep 15, 2017
The commit message here looks like it could be fixing this: v8/v8@81778aa
andrasq commentedon Sep 15, 2017
a variant of
Array.prototype.pop(), it pops but doesn't return the value (returnsundefined)targos commentedon Sep 18, 2017
v8/v8@81778aa was actually merged to V8 6.1 so this issue is fixed on
master.bnoordhuis commentedon Oct 15, 2017
v8.7.0 was released with V8 6.1, which has the fix. I'll close this out.