Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normative: Remove ToUint32 from array literal evaluation
Previously, array literals (including spreads) had their indices and lengths calculated with a ToUint32 operation. As Georg Neis noted in tc39#1095, such a calculation isn't quite right, as 2**32-1 is not an array index. These semantics are unlikely to be observable in many current JavaScript implementations due to resource limitations, but the strange behavior may appear in future, resource-rich implementations. This patch takes Allen Wirfs-Brock's suggestion to simply remove the ToUint32 wraparounds and write to larger indices. When the length is written to, it will throw an exception, after having exhausted any iterators in the literal. Note that too-long Array literals throw only as a runtime exception, not as an early error. In the theoretical case of array indices which exceed the safe numerical integer range, the same semantics will apply--the iterator will be exhausted, and then the write to the length will throw. Internally, the same index will be written repeatedly. This patch includes appropriate use of ? and ! in modified operations.
- Loading branch information