<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:benjamin@webkit.org" title="Benjamin Poulain <benjamin@webkit.org>"> <span class="fn">Benjamin Poulain</span></a>
</span> changed
<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>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>benjamin@webkit.org
</td>
</tr></table>
<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#c16">Comment # 16</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:benjamin@webkit.org" title="Benjamin Poulain <benjamin@webkit.org>"> <span class="fn">Benjamin Poulain</span></a>
</span></b>
<pre><span class="quote">> > > Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h:222
> > > + if (array[index] == target)
> >
> > Isn't that missing the NaN case?
>
> Now I am considering it. However I have a doubt with suspicious cases:
>
> 1. If the searchElement is an Object or a String? In IntXArray, they are
> converted to 0, so "new UInt8Array([0, 1, 2]).includes("abc"); // is true".
> It is not just the case of %TypedArray%.prototype.includes, but also
> %TypedArray%.prototype.indexOf. I didn't find any information about it in
> the Spec. I checked v8 implementation and they return false to these cases.
> IMHO, I think it is the best result, since "new UInt8Array([0, 1,
> 2]).includes("abc");" returning "true" is a potential unpredictable bug
> source.</span >
You are right,
new UInt8Array([0, 1, 2]).includes("abc")
and
new UInt8Array([0, 1, 2]).indexOf("abc")
should return false. Converting the string to a number makes no sense.
The spec does not say to convert the input to a number:
-<a href="https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.indexof">https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.indexof</a>
-<a href="https://tc39.github.io/ecma262/#sec-array.prototype.indexof">https://tc39.github.io/ecma262/#sec-array.prototype.indexof</a>
You have discovered a really stupid bug in the existing indexOf!</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>