Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: DataView methods should throw for absent byteOffset #604

Closed
wants to merge 1 commit into from

Conversation

leobalter
Copy link
Member

ES2016's GetViewValue (and the SetViewValue) throws for undefined byteOffset arg, after #410, it casts to 0 using ToIndex

This change throws a TypeError only when the argument is absent. e.g.: new DataView(buffer, 0).getFloat32()


The alternative for this change is changing GetViewValue and SetViewValue, but that would also affect when the argument is present as undefined and the methods would become slightly different from the normalization introduced with ToIndex.

ES2016's [GetViewValue](https://tc39.github.io/ecma262/2016/#sec-getviewvalue)
(and the SetViewValue) throws for undefined byteOffset arg, after tc39#410,
[it casts to 0 using ToIndex](https://tc39.github.io/ecma262/#sec-getviewvalue)

This change throws a TypeError only when the argument is absent. e.g.:
`new DataView(buffer, 0).getFloat32()`
@leobalter
Copy link
Member Author

Additional info: the previous methods throw a RangeError, this patch throw a TypeError for absent arguments, this is before any further evaluation, including the ToNumber(byteOffset), although, this current positioning is observable before the evaluation for the [[DataView]] internal slot

@leobalter
Copy link
Member Author

btw, I did a quick check and V8, SM and Safari throws a TypeError, but only after checking the [[DataView]] slot.

I used the following jsbin to check: http://jsbin.com/yigifujayo/edit?js,console

@leobalter
Copy link
Member Author

After discussing about this internally, I changed my mind and believe the specs are just fine, no need to fix this.

@leobalter leobalter closed this Jun 14, 2016
@leobalter leobalter deleted the dataview-getmethods branch June 14, 2016 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant