Debian Codegraph @

tests/cli/gc/gc-field-subtyping.wast

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots %
2
3 ;; --enable-gc
4
5 (module
6 ;; When fields are mutable, a subtype's reference fields must be the exact
7 ;; same the supertype's fields (i.e. are invariant).
8 (type $a (sub (struct (field (mut (ref null any))))))
9 (type $b (sub $a (struct (field (mut (ref null any))))))
10
11 ;; When fields are non-mutable, a subtype's reference fields can be subtypes
12 ;; of the supertype's fields (i.e. are covariant).
13 (type $c (sub (struct (field (ref null any)))))
14 (type $d (sub $c (struct (field (ref null none)))))
15 )