Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upClarification requested for interaction between ArraySetLength and Array.protoype.{concat,push,unshift} #1299
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Aug 30, 2018
Member
Yes, the spec. means what it says. The only specified error for your test case is the RangeError when the length of the ExoticArray is set at the end of the algorithm.
You might take a look at the specification of the equivalent method in ES5.1 https://ecma-international.org/ecma-262/5.1/index.html#sec-15.4.4.13
The intent of the ES2015+ version is that for Array Exotic objects the observable behavior should be exactly as specified in 5.1 (and earlier). The significant change applies for objects that aren't Array exotics. They don't get their length ToUint32 converted. You should run your test using an "array -like" object rather than an Array exotic and see what happens.
|
Yes, the spec. means what it says. The only specified error for your test case is the RangeError when the length of the ExoticArray is set at the end of the algorithm. You might take a look at the specification of the equivalent method in ES5.1 https://ecma-international.org/ecma-262/5.1/index.html#sec-15.4.4.13 The intent of the ES2015+ version is that for Array Exotic objects the observable behavior should be exactly as specified in 5.1 (and earlier). The significant change applies for objects that aren't Array exotics. They don't get their length ToUint32 converted. You should run your test using an "array -like" object rather than an Array exotic and see what happens. |
Imasius commentedAug 30, 2018
•
edited
Given the following code example:
The output of eshost is:
If we follow the spec, it says that for Array exotic objects we should observe the behavior of "unshift" [1] and then expect a RangeError when the "length" property of the Array is updated [2]. Chakra and V8 behave this way and I suspect SpiderMonkey as well (I killed the process as it was taking too long).
Is this behavior intended? In all other cases the TyperError (for new lengths > 2 ** 53 - 1) is thrown before "unshift" is executed.
[1]: Array.p.unshift
[2]: ArraySetLength