Skip to content

Conversation

tlively
Copy link
Member

@tlively tlively commented Oct 17, 2025

Specifically ref.get_desc, ref.cast_desc, br_on_cast_desc, and
br_on_cast_desc_fail. Also update the existing br_on_cast and
br_on_cast_fail tests to account for the change to no longer require
the cast output type to be a subtype of the input type.

Specifically ref.get_desc, ref.cast_desc, br_on_cast_desc, and
br_on_cast_desc_fail. Also update the existing br_on_cast and
br_on_cast_fail tests to account for the change to no longer require
the cast output type to be a subtype of the input type.
Copy link
Member

@rossberg rossberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple of nits.

(match_reftype c.types rt2 rt1) e.at
("type mismatch on cast: type " ^ string_of_reftype rt2 ^
" does not match " ^ string_of_reftype rt1);
((top_of_heaptype c.types ht1) = (top_of_heaptype c.types ht2)) e.at
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
((top_of_heaptype c.types ht1) = (top_of_heaptype c.types ht2)) e.at
(top_of_heaptype c.types ht1 = top_of_heaptype c.types ht2) e.at

Similarly below.

Comment on lines +812 to +816
let ut = match ut with
| Some ut -> ut
| None -> error e.at ("type without descriptor " ^ I32.to_string_u x.it)
in
let dt = deftype_of_typeuse ut in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let ut = match ut with
| Some ut -> ut
| None -> error e.at ("type without descriptor " ^ I32.to_string_u x.it)
in
let dt = deftype_of_typeuse ut in
let dt = match ut with
| Some ut -> deftype_of_typeuse ut
| None -> error e.at ("type without descriptor " ^ I32.to_string_u x.it)
in

in
let DescT (_, ut', _) = expand_deftype_to_desctype (type_ c (x @@ at)) in
match ut' with
| Some ut' -> (Null, if exact then ExactHT ut' else UseHT ut')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing this kind of pattern repeat, I wonder if it wouldn't be a more convenient factorisation if exactness was folded into UseHT as a parameter flag, similar to nullability or mutability.

(func (result anyref)
(br_on_cast 0 eqref anyref (unreachable))
(func (param (ref null any)) (result (ref null func))
(block (result (ref null func)) (br_on_cast 1 (ref null any) (ref null func) (local.get 0) (unreachable)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the block redundant?

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

Successfully merging this pull request may close these issues.

2 participants