Closed
Bug 1227207
Opened 10 years ago
Closed 9 years ago
TypedArray constructor throws TypeError when it should throw RangeError
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: lth, Assigned: lth)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
5.53 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
Today's mozilla-inbound. I think it's been this way for a while.
The spec 22.2.1.5 says that TypedArray should throw RangeError if the start offset does not divide the element size or if the end offset minus the start offset does not divide the element size. SpiderMonkey throws TypeError in both cases.
js> var AB = new ArrayBuffer(12)
js> new Int32Array(AB, 2)
typein:3:1 TypeError: invalid arguments
Stack:
@typein:3:1
js> var BC = new ArrayBuffer(14)
js> new Int32Array(BC)
typein:5:1 TypeError: invalid arguments
Stack:
@typein:5:1
js>
Assignee | ||
Comment 1•9 years ago
|
||
Jason, isn't there a bug for tracking spec deviations like this?
Flags: needinfo?(jorendorff)
Comment 2•9 years ago
|
||
No, there's not a separate meta bug for functionality that's implemented in a buggy way. Bug 694100 is the right block-ee for all deviations from spec.
Flags: needinfo?(jorendorff)
Assignee | ||
Comment 3•9 years ago
|
||
Assignee | ||
Comment 4•9 years ago
|
||
Assignee | ||
Comment 5•9 years ago
|
||
Attachment #8753827 -
Flags: review?(jorendorff)
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → lhansen
Status: NEW → ASSIGNED
Comment 6•9 years ago
|
||
Comment on attachment 8753827 [details] [diff] [review]
throw correct error type
Review of attachment 8753827 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks!
::: js/src/vm/TypedArrayObject.cpp
@@ +604,5 @@
> buffer = static_cast<ArrayBufferObjectMaybeShared*>(&AsSharedArrayBuffer(bufobj));
> }
>
> if (byteOffset > buffer->byteLength() || byteOffset % sizeof(NativeType) != 0) {
> + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_INDEX);
The error message this makes is technically correct and *maybe* better than "invalid arguments" but not ideal.
We could splurge and add another error message to js.msg. Your call.
Attachment #8753827 -
Flags: review?(jorendorff) → review+
Assignee | ||
Comment 7•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/8302c77d1f239ce9167eab689692d203d4cb5652
Bug 1227207 - throw correct error type. r=jorendorff
Comment 8•9 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in
before you can comment on or make changes to this bug.
Description
•