Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

rtt implied by ref.func #110

Closed
Closed

Description

@manoskouk

What rtt is implied when allocating a function with ref.func? E.g., how does the following code work?

(type $bar_type ...)
(function $bar (type $bar_type) ... )
(function $foo (type ...) (local funcref) (
  (local.set 0 (ref.func $bar))
  (ref.test (local.get 0) (rtt.canon $bar_type)))

Activity

  1. rossberg commented on Aug 5, 2020

    @rossberg
    Member

    Ah, it's supposed to be the canonical RTT for the function's type, i.e., the test should succeed. I added the missing bullet.

  2. jakobkummerow commented on Aug 5, 2020

    @jakobkummerow
    Contributor

    Just to clarify: IIUC, that means that using rtt.sub with function RTTs is legal but useless, as any custom sub-RTTs created that way can't be used to create any references, because there is no ref.func_with_rtt (akin to struct.new_with_rtt).

    Also, this means that function references created with ref.func can't be ref.casted from anyref to funcref, because their RTT is not a sub-RTT of the funcref RTT. (This is similar to i31ref not being downcastable from anyref to eqref.) I personally don't have any objections to this limitation, though I do wonder whether there are any real-world use cases that would find this inconvenient.

  3. RossTate commented on Aug 13, 2020

    @RossTate
    Contributor

    @rossberg Your answer here contradicts the MVP document, which says that rtt.is_func would be equivalent to (rtt.canon func) (ref.test). This issue should probably be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions