<?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>260039</bug_id>
          
          <creation_ts>2023-08-10 13:58:01 -0700</creation_ts>
          <short_desc>[Wasm-GC] Module linking should take subtyping into account</short_desc>
          <delta_ts>2023-12-18 09:55:08 -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>WebAssembly</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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>
          
          <blocked>247394</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Asumu Takikawa">asumu</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1970571</commentid>
    <comment_count>0</comment_count>
    <who name="Asumu Takikawa">asumu</who>
    <bug_when>2023-08-10 13:58:01 -0700</bug_when>
    <thetext>Right now, module linking checks for exact type index equality to make sure linked functions satisfy their types. The GC proposal extends this to work with subtypes, instead of exact match, but this isn&apos;t implemented yet.

For example, this test fragment is from the GC proposal repo test suite:

```
(module
  (type $t0 (sub (func (result (ref null func)))))
  (rec (type $t1 (sub $t0 (func (result (ref null $t1))))))
  (rec (type $t2 (sub $t1 (func (result (ref null $t2))))))

  (func (export &quot;f0&quot;) (type $t0) (ref.null func))
  (func (export &quot;f1&quot;) (type $t1) (ref.null $t1))
  (func (export &quot;f2&quot;) (type $t2) (ref.null $t2))
)
(register &quot;M&quot;)

(module
  (type $t0 (sub (func (result (ref null func)))))
  (rec (type $t1 (sub $t0 (func (result (ref null $t1))))))
  (rec (type $t2 (sub $t1 (func (result (ref null $t2))))))

  (func (import &quot;M&quot; &quot;f0&quot;) (type $t0))
  (func (import &quot;M&quot; &quot;f1&quot;) (type $t0))
  (func (import &quot;M&quot; &quot;f1&quot;) (type $t1))
  (func (import &quot;M&quot; &quot;f2&quot;) (type $t0))
  (func (import &quot;M&quot; &quot;f2&quot;) (type $t1))
  (func (import &quot;M&quot; &quot;f2&quot;) (type $t2))
)
```

The import &quot;f1&quot; takes a function that has type `$t1` (subtype of `$t0`) and tries to import it under type `$t0`. This currently fails, but is supposed to succeed.

It should be relatively easy to fix, by changing the index equality check to a `isSubtype` call.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1971908</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-08-17 13:58:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/114045477&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1999976</commentid>
    <comment_count>2</comment_count>
    <who name="Asumu Takikawa">asumu</who>
    <bug_when>2023-12-15 10:28:12 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/21875</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2000456</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-12-18 09:55:06 -0800</bug_when>
    <thetext>Committed 272226@main (3015bbe0e8ab): &lt;https://commits.webkit.org/272226@main&gt;

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

    </bug>

</bugzilla>