Skip to content

Explanation of type matching in ref_test tests #511

Answered by rossberg
q82419 asked this question in Q&A
Discussion options

You must be logged in to vote

By subsumption, the instruction (ref.null $t1) also has type [] → [(ref null any)], and (ref null any) is a suitable rt' that is a supertype of (ref null $t0).

This is a bit of a trick of the kind sometimes used in the specification of type systems. What the rule is saying is that you can weaken the operand type to anything less precise than rt (since it's a downcast anyway). Implicitly, what it is really saying is that you can always pick the corresponding top type. Before we introduced the different subtype hierarchies (any/func/extern), ref.test in fact simply had type [anyref] → [i32]. The current formulation allows picking funcref or externref instead as the top type suitable for rt.

S…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@rossberg
Comment options

@q82419
Comment options

@rossberg
Comment options

@q82419
Comment options

@rossberg
Comment options

Answer selected by q82419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants