Can we make a new error message such as "The offset is out of range of the buffer" for this? This error occurs because the new length is negative, but it does not mean that the new length is not a multiple of X.
v… via monorail
unread,
Feb 12, 2017, 11:37:04 AM2/12/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
Looking at https://codereview.chromium.org/2090353003, which introduced the current code, the previously used RangeError variant was kInvalidTypedArrayOffset, which is currently missing from the list in messages.h. Because this is about typed arrays and not DataViews, kInvalidTypedArrayOffset will need to be introduced again. I'll do that and let the reviewer express potential concerns.
v… via monorail
unread,
Feb 12, 2017, 12:44:05 PM2/12/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
The constructor for TypedArray in js/typedarray.js emitted kInvalidTypedArrayAlignment if the array offset exceeded the size of the underlying buffer. This seems like a typo introduced in https://codereview.chromium.org/2090353003.
The error message to be emitted instead coincides with the already existing kInvalidDataViewOffset. The message string is independent of whether the object in question is a DataView or a typed array, so this CL: (1) renames kInvalidDataViewOffset to just kInvalidOffset, and (2) uses kInvalidOffset instead of kInvalidTypedArrayAlignment for cases when the TypedArray is constructed with an offset exceeding the buffer size.
BUG=v8:5733 TEST=Run d8, execute "new Uint8Array(new ArrayBuffer(1),2)", see the error message mention the invalid offset 2.