Debian Codegraph @

tests/cli/gc/gc-subtypes.wast

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots %
2
3 ;; --enable-gc
4
5 (module
6 ;; nullability matching for field types
7 (type $non_null (sub (array (ref null any))))
8 (type $nullable (sub $non_null (array (ref any))))
9
10 ;; struct width and depth subtyping
11 (type $struct_base (sub (struct)))
12 (type $struct_width (sub $struct_base (struct (field (ref null $struct_base)))))
13 (type $struct_depth (sub $struct_width (struct (field (ref $struct_base)))))
14
15 ;; function param and result subtyping
16 (type $func_base (sub (func (param eqref) (result eqref))))
17 (type $func_contravariant_params (sub $func_base (func (param anyref) (result eqref))))
18 (type $func_covariant_results (sub $func_base (func (param eqref) (result nullref))))
19
20 ;; any refs
21 (type $any (sub (array anyref)))
22 (type $any_2 (sub $any (array anyref)))
23 (type $any_mut (sub (array (mut anyref))))
24 (type $any_mut_2 (sub $any_mut (array (mut anyref))))
25
26 ;; eq refs
27 (type $eq (sub $any (array eqref)))
28 (type $eq_2 (sub $eq (array eqref)))
29 (type $eq_mut (sub (array (mut eqref))))
30 (type $eq_mut_2 (sub $eq_mut (array (mut eqref))))
31
32 ;; i31 refs
33 (type $i31 (sub $eq (array i31ref)))
34 (type $i31_2 (sub $i31 (array i31ref)))
35 (type $i31_mut (sub (array (mut i31ref))))
36 (type $i31_mut_2 (sub $i31_mut (array (mut i31ref))))
37
38 ;; array refs
39 (type $array (sub $eq (array arrayref)))
40 (type $array_2 (sub $array (array arrayref)))
41 (type $array_mut (sub (array (mut arrayref))))
42 (type $array_mut_2 (sub $array_mut (array (mut arrayref))))
43
44 ;; concrete array refs
45 (type $concrete_array (sub $array (array (ref null $array))))
46 (type $concrete_array_2 (sub $concrete_array (array (ref null $array))))
47 (type $concrete_array_mut (sub (array (ref null $array_mut))))
48 (type $concrete_array_mut_2 (sub $concrete_array_mut (array (ref null $array_mut))))
49
50 ;; struct refs
51 (type $struct (sub $eq (array structref)))
52 (type $struct_2 (sub $struct (array structref)))
53 (type $struct_mut (sub (array (mut structref))))
54 (type $struct_mut_2 (sub $struct_mut (array (mut structref))))
55
56 ;; concrete struct refs
57 (type $my_struct (struct))
58 (type $concrete_struct (sub $struct (array (ref null $my_struct))))
59 (type $concrete_struct_2 (sub $concrete_struct (array (ref null $my_struct))))
60 (type $concrete_struct_mut (sub (array (mut (ref null $my_struct)))))
61 (type $concrete_struct_mut_2 (sub $concrete_struct_mut (array (mut (ref null $my_struct)))))
62
63 ;; none refs
64 (type $none (sub (array nullref)))
65 (type $none_2 (sub $none (array nullref)))
66 (type $none_any (sub $any (array nullref)))
67 (type $none_any_2 (sub $none_any (array nullref)))
68 (type $none_eq (sub $eq (array nullref)))
69 (type $none_eq_2 (sub $none_eq (array nullref)))
70 (type $none_i31 (sub $i31 (array nullref)))
71 (type $none_i31_2 (sub $none_i31 (array nullref)))
72 (type $none_array (sub $array (array nullref)))
73 (type $none_array_2 (sub $none_array (array nullref)))
74 (type $none_concrete_array (sub $concrete_array (array nullref)))
75 (type $none_concrete_array_2 (sub $none_concrete_array (array nullref)))
76 (type $none_struct (sub $struct (array nullref)))
77 (type $none_struct_2 (sub $none_struct (array nullref)))
78 (type $none_concrete_struct (sub $concrete_struct (array nullref)))
79 (type $none_concrete_struct_2 (sub $none_concrete_struct (array nullref)))
80 (type $none_mut (sub (array (mut nullref))))
81 (type $none_mut_2 (sub $none_mut (array (mut nullref))))
82
83 ;; func refs
84 (type $func (sub (array funcref)))
85 (type $func_2 (sub $func (array funcref)))
86 (type $func_mut (sub (array (mut funcref))))
87 (type $func_mut_2 (sub $func_mut (array (mut funcref))))
88
89 ;; concrete func refs
90 (type $my_func (func))
91 (type $concrete_func (sub $func (array (ref null $my_func))))
92 (type $concrete_func_2 (sub $concrete_func (array (ref null $my_func))))
93 (type $concrete_func_mut (sub (array (mut (ref null $my_func)))))
94 (type $concrete_func_mut_2 (sub $concrete_func_mut (array (mut (ref null $my_func)))))
95
96 ;; nofunc
97 (type $nofunc (sub $concrete_func (array nullfuncref)))
98 (type $nofunc_2 (sub $nofunc (array nullfuncref)))
99 (type $nofunc_mut (sub (array (mut nullfuncref))))
100 (type $nofunc_mut_2 (sub $nofunc_mut (array (mut nullfuncref))))
101
102 ;; extern refs
103 (type $extern (sub (array externref)))
104 (type $extern_2 (sub $extern (array externref)))
105 (type $extern_mut (sub (array (mut externref))))
106 (type $extern_mut_2 (sub $extern_mut (array (mut externref))))
107
108 ;; noextern
109 (type $noextern (sub $extern (array nullexternref)))
110 (type $noextern_2 (sub $noextern (array nullexternref)))
111 (type $noextern_mut (sub (array (mut nullexternref))))
112 (type $noextern_mut_2 (sub $noextern_mut (array (mut nullexternref))))
113
114 ;; field names
115 (type $struct_with_named_field (sub (struct (field $field (mut i32)))))
116 ;; same field, same name
117 (type (sub $struct_with_named_field (struct (field $field (mut i32)))))
118 ;; same field, different name
119 (type (sub $struct_with_named_field (struct (field $different (mut i32)))))
120 ;; different field, same name
121 (type (sub $struct_with_named_field (struct (field (mut i32)) (field $field (mut i64)))))
122 )