<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - ECMAScript 2016: %TypedArray%.prototype.includes implementation"
href="https://bugs.webkit.org/show_bug.cgi?id=159385#c21">Comment # 21</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - ECMAScript 2016: %TypedArray%.prototype.includes implementation"
href="https://bugs.webkit.org/show_bug.cgi?id=159385">bug 159385</a>
from <span class="vcard"><a class="email" href="mailto:ticaiolima@gmail.com" title="Caio Lima <ticaiolima@gmail.com>"> <span class="fn">Caio Lima</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=282752&action=diff" name="attach_282752" title="Patch">attachment 282752</a> <a href="attachment.cgi?id=282752&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=282752&action=review">https://bugs.webkit.org/attachment.cgi?id=282752&action=review</a>
<span class="quote">>> Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h:216
>> + if (!valueToFind.isNumber() && !valueToFind.isDouble())
>
> Isn't "isNumber()" a superset of "isDouble()"?
>
> valueToFind.isNumber() false implies valueToFind.isDouble() false.</span >
You are right. I was considering isDouble because of NaN case, bit Ironically, NaN isNumber is true.
<span class="quote">>> Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h:222
>> + typename ViewClass::ElementType target = ViewClass::toAdaptorNativeFromValue(exec, valueToFind);
>
> I don't think that works for includes.
>
> For example, Uint8ClampedAdaptor will clamp positive values to 255, that's not what we need here.
> IntegralTypedArrayAdaptor does ToInt32 on the input, that's not what we need either.
>
> Your test should have extensive coverage of those crazy cases.
>
> ----
>
> What you probably need is a new Adaptor function that returns a value in the right type or an error.
>
> For example, if you pass a double to an integer type array, it returns the integer if it fits in the array type or fail.
> E.g.:
> -The double 256.0 works for int16, fails for int8
> -The double 254.1 fails for all integers.</span >
Nice point. I am working in that now.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>