New issue
Advanced search Search tips
Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
HW: ----
NextAction: ----
OS: ----
Priority: 2
Type: Bug



Sign in to add a comment

TypedArray constructor should not use iterator for typed arrays

Reported by zloir...@gmail.com, Nov 17 2015

Issue description

```
var a = new Uint8Array([1, 2, 3, 4]);
a[Symbol.iterator] = _ => [4, 3, 2, 1][Symbol.iterator]();
new Uint8Array(a); // => [4, 3, 2, 1], should be [1, 2, 3, 4]
```
http://www.ecma-international.org/ecma-262/6.0/#sec-%typedarray%-object
http://www.ecma-international.org/ecma-262/6.0/#sec-%typedarray%-typedarray
 

Comment 1 by zloir...@gmail.com, Nov 17 2015

new Uint8Array(null) -> TypeError, should be []
new Uint8Array() -> [], should be TypeError
new Uint8Array(undefined) -> [], should be TypeError
new Uint8Array(1.5) -> [0], should be RangeError
...
Cc: rossberg@chromium.org adamk@chromium.org dehrenberg@chromium.org
Labels: Type-Bug Harmony Priority-Medium Area-Language
Status: Available
Owner: littledan@chromium.org
Status: Assigned (was: Available)
This should definitely be addressed, but I'm worried about the web compat implications. These are being discussed upstream at https://github.com/tc39/ecma262/issues/265 but they have not been brought to discussion in TC39 committee time. I think we can make some improvements without risking compat, but it will be tricky to figure out what exactly to do and what not to do.
core.js rolled back part of this change due to compat issues: https://github.com/karma-runner/karma/issues/1768

Comment 6 by zloir...@gmail.com, Feb 24 2016

FF already has a correct length validation here + it can be fixed on NodeJS side only for Buffer, so I don't think it can be reverted from the spec.
Labels: Priority-2

Comment 8 by adamk@chromium.org, Dec 19 2017

Cc: -dehrenberg@chromium.org -rossberg@chromium.org
Did this get resolved on the spec side?

Sign in to add a comment