Some Array methods don't consider array holes and length
On Jun 25, 2012, at 1:18 AM, Yusuke Suzuki wrote:
Hello,
In some Array methods such as 'slice', 'splice', they don't [[Put]] 'length' value. And they check [[HasProperty]] before [[DefineOwnProperty]]. As the result, they waste empty trailing elements, but it is not compatible behavior to ES3.
For splice, this has already been reported as ecmascript#332 concat is bug ecmascript#129
I've added a new bug for slice: ecmascript#417
Are there any other cases like these that you have identified?
For splice, this has already been reported as ecmascript#332
Oh, I missed it, thanks!! I've added myself to CC.
I've added a new bug for slice:
Thanks for filing this.
Are there any other cases like these that you have identified?
As long as I know, all cases have been already reported. For example, old Array.from spec had the same problem. But in the latest draft, [[Put]] 'length' is inserted, so this issue doesn't occur. gist.github.com/1074126
, Yusuke Suzuki
On Tue, Jun 26, 2012 at 9:01 AM, Yusuke Suzuki <utatane.tea at gmail.com>wrote:
For splice, this has already been reported as
Oh, I missed it, thanks!! I've added myself to CC.
I've added a new bug for slice:
Thanks for filing this.
Are there any other cases like these that you have identified?
As long as I know, all cases have been already reported. For example, old Array.from spec had the same problem. But in the latest draft, [[Put]] 'length' is inserted, so this issue doesn't occur. gist.github.com/1074126
Sorry for any confusion - I wrote that as a "proof of concept". The draft that Allen produces should be considered the canonical document to follow for spec developments moving towards ES6 standardization.
Hello,
In some Array methods such as 'slice', 'splice', they don't [[Put]] 'length' value. And they check [[HasProperty]] before [[DefineOwnProperty]]. As the result, they waste empty trailing elements, but it is not compatible behavior to ES3.
For example,
In ES3, this result is [0,,,,] and length is 4. But, in ES5.1 algorithm step 10-k, kPresent is true when only the first case comes, so result A is [0] and length is 1.
All the modern engines behave like ES3, so I think this is issue of ES5.1, is it right?
The issue of the same kind was found before in Array.prototype.concat, and I reported it. mail.mozilla.org/pipermail/es5-discuss/2010-December/003851.html
And A of Array.prototype.splice has the same problem. In section 15.4.4.12 step 9-c, we check fromPresent and [[DefineOwnProperty]] to A, but we don't perform [[Put]] length operation to A.
For example,
In ES3, this result is [0,,,] and length is 4. But, in ES5.1 algorithm step 9-c, fromPresent is true when only the first case comes, so result A is [0] and length is 1.
So I suggest updating spec template that returns Array.
P.S. Sorry for duplicate mails, they're reflected lately, so I thought they are filtered.
, Yusuke Suzuki