-
Notifications
You must be signed in to change notification settings - Fork 472
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
SameValue is too strict and used incorrectly for some tests #435
Comments
Great catch. This part should definitely be made more explicit in the specification, because the major implementations show different results for
And I also agree on |
There is a similar issue in %TypedArray% ( buffer [ , byteOffset [ , length ] ] ), steps 7-8 and step 17:
That means it's possible to store
|
Created https://bugs.ecmascript.org/show_bug.cgi?id=4544 and https://bugs.ecmascript.org/show_bug.cgi?id=4545 to track these issues. @bterlson Any recommendation for this issue? I'd prefer resolving bug 4545 instead of replacing SameValue with |
Fixing 4545 seems correct. IMO we should make indexOf return 0 not -0 because preserving -0s would require an implementation of the internal Math ops that preserve -0 and refactorings to use them in at least String#indexOf/lastIndexOf and Array#lastIndexOf. I might venture to say that last(?)IndexOf implementations deliberately convert -0 to 0 and Array#indexOf is simply bugged but maybe @allenwb could comment on his intent. |
Well V8, for one, implements it per spec now, returning -0 and failing this test! |
@littledan V8/SM gets lastIndex wrong, though: |
I agree that spec'ing it at 0 would make sense. (But, pedantically, I think, according to the current spec, -0 is a valid return value.) |
I agree that the current spec says -0 is correct for indexOf (not lastIndexOf, though). |
indexOf with a startIndex of -0 should return 0 now. We should get a test for this checked in :) |
…et, ...) constructor Ref tc39#435
The last commit on #485 is covering the byteOffset -0 conversion on TypedArray( buffer, ... ) constructors. |
It looks like the patch at 9ccc663 replaced === in a number of tests with SameValue. While it's nice to tighten things up in general, I'm not sure if the changes are all valid.
For example, in the test built-ins/Array/prototype/indexOf/15.4.4.14-5-9 , -0 is given as the starting index, and 0 is expected as the output (when the answer is found at index 0). By my reading of the spec, -0 would be the right answer (though it's a little ambiguous since the font makes it look like we left float-world and we're in math-land). Would it make sense to change the SameValue test back to ===, or use -0 in this particular test?
The text was updated successfully, but these errors were encountered: