Forum Bugs

Array.prototype.slice does not respect actual length of source array

natevw
The implementation of Array.prototype.slice within Prince is buggy.

When called with no arguments, or with arguments of e.g. `arr.slice(0,arr.length)` it should always return a new array with the same length as the source.

However, Prince's implementation appears to truncate the returned array after the last defined value. For example with the following setup:

var x = [];
x[5] = true;
x.length = 10;


…a correct JavaScript implementation will have `x.slice().length === 10`. However in Prince we get `x.slice().length === 6` instead.

I've attached a more complete demo that can be run via `prince ---javascript` to demonstrate a variety of results, pointing out the ones it gets wrong.
  1. prince_slice.html0.8 kB
mikeday
Thanks! We will fix this issue.
mikeday
We have fixed this issue now in Prince 13.2, thanks again for letting us know! :D