Skip to content

Float numbers not pushed into array. #15427

Closed
@SkeLLLa

Description

@SkeLLLa

In two words: float numbers not pushed into array if in push function shift is called.

Version: 8.5.0
Platform: linux x86_64

class FixedArray extends Array {
  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));
    }
  }
}

var ddd = new FixedArray(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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions