Clarifying ref.is_null matching validation #547
-
I'd like to understand the following excerpt: does (ref null bot) -> (i32) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The type bot is a valid heap type — and (ref null bot) hence a valid reference type — so the rule would allow picking it. However, that choice usually isn't useful as an input type, since there are no actual values of that type and hence this would normally not allow successfully typing an instruction sequence in which this instruction occurs. You need something that is a supertype of the actual operand type, not a subtype. In the usual algorithmic implementation of validation, you always know what's on the operand stack, so you just take that type directly. See the spec's Appendix for an implementation sketch. |
Beta Was this translation helpful? Give feedback.
The type bot is a valid heap type — and (ref null bot) hence a valid reference type — so the rule would allow picking it. However, that choice usually isn't useful as an input type, since there are no actual values of that type and hence this would normally not allow successfully typing an instruction sequence in which this instruction occurs. You need something that is a supertype of the actual operand type, not a subtype.
In the usual algorithmic implementation of validation, you always know what's on the operand stack, so you just take that type directly. See the spec's Appendix for an implementation sketch.