Closed Bug 1255165 Opened 4 years ago Closed 4 months ago

TypeArray.prototype.set needs a better error message than "invalid array length".

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox48 --- wontfix
firefox68 --- fixed

People

(Reporter: nbp, Assigned: vi.le, 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
Blocks: jserror
Mentor: arai.unmht
Can I work on this bug?
Flags: needinfo?(arai.unmht)
sure
Flags: needinfo?(arai.unmht)
ok thanks

Hi, can I work on this? :-)

Vincent

Flags: needinfo?(arai.unmht)

yes :)
see the comment #3 for the details.
feel free to ask question here, or #jsapi IRC channel

Flags: needinfo?(arai.unmht)

Thanks!

Assignee: nobody → vi.le
Status: NEW → ASSIGNED
Flags: needinfo?(arai.unmht)

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)
Keywords: checkin-needed

Thanks! I have added the label as the test failures seem only intermittent.

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
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
You need to log in before you can comment on or make changes to this bug.