<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>261815</bug_id>
          
          <creation_ts>2023-09-20 04:33:52 -0700</creation_ts>
          <short_desc>[JSC] Stress tests have bogus asserts due to incorrectly negating `instanceof` operator</short_desc>
          <delta_ts>2024-02-28 00:36:03 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tools / Tests</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>pablo.gobe</reporter>
          <assigned_to name="Alexey Shvayka">ashvayka</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ashvayka</cc>
    
    <cc>mark.lam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1978621</commentid>
    <comment_count>0</comment_count>
    <who name="">pablo.gobe</who>
    <bug_when>2023-09-20 04:33:52 -0700</bug_when>
    <thetext>`in` and `instanceof` expressions in JS
```js
a in obj;
a instanceof C;
```
can be negated by grouping them and applying the `!` operator, i.e.

```js
!(a in obj);
!(a instanceof C);
```

Applying the `!` operator incorrectly (on the LHS operand) leads to bugs:
```js
!a in obj; // will evaluate to false, unless obj has a &quot;true&quot; or &quot;false&quot; key
!a instanceof C; // will evaluate to false, unless C overrides instanceof with a @@hasInstance method
```
For more information, please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#not_an_instanceof and the no-unsafe-negation recommended Eslint rule, https://eslint.org/docs/latest/rules/no-unsafe-negation.

I have found several potentially problematic instances of the above bugs in your codebase:

`in` bugs:
https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/WebKit/WebKit%24+lang:javascript+/%5C%21%5B%5B:alnum:%5D%5C%27%5C%22%5D%2B+in+%5B%5B:alnum:%5D%5D%2B/+-file:%5C.min%5C.js%24+count:all&amp;patternType=standard&amp;sm=1&amp;groupBy=repo

`instanceof` bugs:
https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/WebKit/WebKit%24+lang:javascript+/%5C%21%5B%5B:alnum:%5D%5D%2B+instanceof+%5B%5B:alnum:%5D%5D%2B/+-file:%5C.min%5C.js%24+count:all&amp;patternType=standard&amp;sm=1&amp;groupBy=repo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1980466</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-09-27 04:34:13 -0700</bug_when>
    <thetext>&lt;rdar://problem/116114756&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2017400</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2024-02-27 22:07:32 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/25215</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2017418</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-02-28 00:36:01 -0800</bug_when>
    <thetext>Committed 275433@main (d4af38db1147): &lt;https://commits.webkit.org/275433@main&gt;

Reviewed commits have been landed. Closing PR #25215 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>