Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtt implied by ref.func #110

Closed
manoskouk opened this issue Aug 3, 2020 · 3 comments
Closed

rtt implied by ref.func #110

manoskouk opened this issue Aug 3, 2020 · 3 comments

Comments

@manoskouk
Copy link
Contributor

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)))
@rossberg
Copy link
Member

rossberg commented Aug 5, 2020

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.

@rossberg rossberg closed this as completed Aug 5, 2020
@jakobkummerow
Copy link
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.

@RossTate
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants