Closed
Bug 1255165
Opened 10 years ago
Closed 6 years ago
TypeArray.prototype.set needs a better error message than "invalid array length".
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla68
People
(Reporter: nbp, Assigned: vincent, Mentored)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
While documenting "invalid array length" [1] error, I noticed that we have the same error for TypeArray.prototype.set[2] function.
I think TypeArray.prototype.set needs a better error message when the origin is larger than the remaining space of the target.
In SpiderMonkey:
> var t = new Uint32Array(1);
> var t2 = new Uint32Array(3);
> t.set(t2)
RangeError: invalid array length
In v8:
> var t = new Uint32Array(1);
> var t2 = new Uint32Array(3);
> t.set(t2)
RangeError: Source is too large
Also, this error does not seems to be documented on the TypedArray.prototype.set page.
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length
[1] https://dxr.mozilla.org/mozilla-central/source/js/src/vm/TypedArrayCommon.h#819,831
[2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set
Updated•7 years ago
|
Mentor: arai.unmht
Comment 3•7 years ago
|
||
I suppose you've commented to the wrong bug.
anyway,
Required code changes are following:
* Add a new error message for the case when the source array's length is too long [1]
* Modify TypedArrayObject::set_impl [2] to throw the new error for the cases [3][4]
You'll need basic knowledge of C++, and be able to build and test Firefox [5] or SpiderMonkey [6].
[1] https://searchfox.org/mozilla-central/rev/f0c15db995198a1013e1c5f5b5bea54ef83f1049/js/src/js.msg#552
[2] https://searchfox.org/mozilla-central/rev/f0c15db995198a1013e1c5f5b5bea54ef83f1049/js/src/vm/TypedArrayObject.cpp#1470
[3] https://searchfox.org/mozilla-central/rev/f0c15db995198a1013e1c5f5b5bea54ef83f1049/js/src/vm/TypedArrayObject.cpp#1539
[4] https://searchfox.org/mozilla-central/rev/f0c15db995198a1013e1c5f5b5bea54ef83f1049/js/src/vm/TypedArrayObject.cpp#1577
[5] https://developer.mozilla.org/en-US/docs/Simple_Firefox_build
[6] https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Build_Documentation
Comment 6•7 years ago
|
||
yes :)
see the comment #3 for the details.
feel free to ask question here, or #jsapi IRC channel
Flags: needinfo?(arai.unmht)
| Assignee | ||
Comment 7•7 years ago
|
||
Thanks!
| Assignee | ||
Updated•7 years ago
|
Assignee: nobody → vi.le
| Assignee | ||
Updated•7 years ago
|
Status: NEW → ASSIGNED
| Assignee | ||
Comment 8•7 years ago
|
||
Updated•6 years ago
|
Flags: needinfo?(arai.unmht)
Comment 9•6 years ago
|
||
here's try run
https://treeherder.mozilla.org/#/jobs?repo=try&revision=941e1dbfd00a435f49d6fb7b4a498273bc6dc6e4
once it finishes without any issue, you can add "checkin-needed" to keyword field, so that your patch will be landed.
Flags: needinfo?(arai.unmht)
| Assignee | ||
Updated•6 years ago
|
Keywords: checkin-needed
| Assignee | ||
Comment 10•6 years ago
|
||
Thanks! I have added the label as the test failures seem only intermittent.
Comment 11•6 years ago
|
||
Pushed by archaeopteryx@coole-files.de:
https://hg.mozilla.org/integration/autoland/rev/26d207ba289e
Improve error message for TypeArray.prototype.set if source array is too large;r=arai
Keywords: checkin-needed
Comment 12•6 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox68:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
Updated•6 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•