archives

« Bugzilla Issues Index

#1400 — TypedArray: @@elementGet and @@elementSet should not clamp negative indices to 0


Sections 15.13.6.6.10 and 15.13.6.6.11 (@elementGet and @@elementSet for TypedArray) prescribe to apply ToPositiveInteger to the index argument to get the index to the buffer (step 8 in both sections)

This has the effect that accesses with negative indices, as well as accesses with non-numeric indices, are equivalent to accesses to zero element.

This is inconsistent with both the behavior for large out-of-bounds indices (for indices greater than length get returns undefined, set has no effect), and all known current implementations of TypedArrays.

The consensus between all implementations is to return undefined for all read out-of-bounds accesses for typed arrays and making write out-of-bounds operation a no-op ("arr[-1] = f()" executes f(), does not change the array the result of the operation is the return value of f()).


fixed in rev16 editor's draft


fixed in rev16 draft. July 15, 2013