-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ArrayBuffer() & ArrayBuffer("some non-number") doesn't match implementations #265
Comments
Interestingly, as far as I can tell, ToLength was added exactly to support large TypedArrays. I think we should remain compatible with web usage and what implementations do, but I wonder if we can do it in a way which generally preserves some kind of consistency with ToLength. As a strawman, what if we just replaced lines 3-6 with a simple ToLength call? That would handle coercing all sorts of things to 0, while guaranteeing that we're left with a positive integer. It would be a minor change vs current browser behavior, but as far as I can tell, it would only be in the direction of not throwing on negative numbers (where V8, for one, currently throws). An alternative would be
which would leave us with that nice, higher level of checking, and verifying that the result is within (2**53)* range, while still allowing undefined etc to be coerced in a web-compatible way. * To be unambiguous, I put parens around all exponentiation |
Another place where this comes up is DataView setting/getting indices. Across all four browsers (at least for the last Safari release, and more recent versions of all other browsers), if I try to set something at the 'NaN' index, no exception is thrown. However, a new set of tests in the same patch by @anba highlighted that this violates the spec. |
Currently, I use this inconsistency as an ultimative feature detection for wrapping |
First of all I think it's hard to believe web-compatibility is affected when But more importantly argument input validation should be consistent across ArrayBuffer, DataView and TypedArray, because all three are used together [0]. So if it gets decided that Current situation for Current situation for [0] It's already not quite consistent when you compare the length parameter checks in 22.2.1.2 and 22.2.1.5. |
Ok. The first day of |
Also, for example, |
So... With this change for |
Do we consider this fixed with #410 ? |
yes, this can be closed |
@anba contributed these tests and highlighted an issue. See also this v8 issue. No browser as far as I can tell implements the required ToNumber semantics. Considering we already have interoperable implementation here I doubt this will change. Seems like we should just do ToInteger rather than the ToNumber/ToLength incantation presently in 22.2.1.2. Thoughts?
The text was updated successfully, but these errors were encountered: