Debian Codegraph @

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

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots %
2
3 ;; --enable-gc
4
5 (assert_invalid
6 (module
7 ;; When fields are mutable, a subtype's reference fields cannot be subtypes of
8 ;; the supertype's fields, they must match exactly.
9 (type $a (sub (struct (field (mut (ref null any))))))
10 (type $b (sub $a (struct (field (mut (ref null none))))))
11 )
12 "sub type must match super type"
13 )
14
15 (assert_invalid
16 (module
17 ;; When fields are const, a subtype's reference fields cannot be supertypes of
18 ;; the supertype's fields, they must be subtypes.
19 (type $a (sub (struct (field (mut (ref null none))))))
20 (type $b (sub $a (struct (field (mut (ref null any))))))
21 )
22 "sub type must match super type"
23 )
24
25 (assert_invalid
26 (module
27 ;; The mutability of fields must be the same.
28 (type $c (sub (struct (field (mut (ref null any))))))
29 (type $d (sub $c (struct (field (ref null none)))))
30 )
31 "sub type must match super type"
32 )
33
34 (assert_invalid
35 (module
36 ;; The mutability of fields must be the same.
37 (type $c (sub (struct (field (ref null any)))))
38 (type $d (sub $c (struct (field (mut (ref null none))))))
39 )
40 "sub type must match super type"
41 )