|
1 | 1 | ;; --enable-gc
|
2 | 2 |
|
3 | 3 | (module
|
4 |
| - (type $a (sub (func))) |
5 |
| - (type $b (sub $a (func))) |
6 |
| - (type $c (sub $b (func))) |
7 |
| - (type $b1 (sub final $a (func))) |
| 4 | + ;; nullability matching for field types |
| 5 | + (type $non_null (sub (array (ref null any)))) |
| 6 | + (type $nullable (sub $non_null (array (ref any)))) |
8 | 7 |
|
9 |
| - ;; struct, ref types, mutability, nullability |
10 |
| - (type $d (sub (struct))) |
11 |
| - (type $e (sub $d (struct (field (mut (ref null $d)))))) ;; width |
12 |
| - (type $f (sub final $e (struct (field (ref $e))))) ;; depth |
| 8 | + ;; struct width and depth subtyping |
| 9 | + (type $struct_base (sub (struct))) |
| 10 | + (type $struct_width (sub $struct_base (struct (field (ref null $struct_base))))) |
| 11 | + (type $struct_depth (sub $struct_width (struct (field (ref $struct_base))))) |
13 | 12 |
|
14 |
| - ;; func |
15 |
| - (type $g (sub (func (param (ref $e)) (result (ref $e))))) |
16 |
| - (type $h (sub $g (func (param (ref $d)) (result (ref $f))))) |
17 |
| - |
18 |
| - (type $j (sub (func (param (ref $b)) (result (ref $b))))) |
19 |
| - (type $k (sub $j (func (param (ref $a)) (result (ref $c))))) |
20 |
| - |
21 |
| - ;; valid: expanded param/result types are equal to those of the parent |
22 |
| - (type $l (sub $j (func (param (ref $b)) (result (ref $b))))) |
23 |
| - |
24 |
| - ;; array, val types, ref types, mutability, nullability |
25 |
| - (type $m (sub (array (mut i32)))) |
26 |
| - (type $n (sub $m (array i32))) |
27 |
| - |
28 |
| - (type $o (sub (array i32))) |
29 |
| - (type $p (sub $o (array i32))) |
30 |
| - |
31 |
| - (type $o1 (sub (array i64))) |
32 |
| - (type $p1 (sub $o1 (array i64))) |
| 13 | + ;; function param and result subtyping |
| 14 | + (type $func_base (sub (func (param eqref) (result eqref)))) |
| 15 | + (type $func_contravariant_params (sub $func_base (func (param anyref) (result eqref)))) |
| 16 | + (type $func_covariant_results (sub $func_base (func (param eqref) (result nullref)))) |
33 | 17 |
|
34 | 18 | ;; any refs
|
35 |
| - (type $q (sub (array (mut anyref)))) |
36 |
| - (type $q0 (sub $q (array (ref any)))) |
| 19 | + (type $any (sub (array anyref))) |
| 20 | + (type $any_2 (sub $any (array anyref))) |
| 21 | + (type $any_mut (sub (array (mut anyref)))) |
| 22 | + (type $any_mut_2 (sub $any_mut (array (mut anyref)))) |
37 | 23 |
|
38 | 24 | ;; eq refs
|
39 |
| - (type $q1 (sub $q (array (mut eqref)))) |
40 |
| - (type $q2 (sub $q1 (array (mut (ref eq))))) |
41 |
| - (type $q3 (sub $q2 (array (ref eq)))) |
| 25 | + (type $eq (sub $any (array eqref))) |
| 26 | + (type $eq_2 (sub $eq (array eqref))) |
| 27 | + (type $eq_mut (sub (array (mut eqref)))) |
| 28 | + (type $eq_mut_2 (sub $eq_mut (array (mut eqref)))) |
42 | 29 |
|
43 | 30 | ;; i31 refs
|
44 |
| - (type $r (sub $q (array i31ref))) |
45 |
| - (type $r1 (sub $q1 (array i31ref))) |
46 |
| - (type $s (sub $r (array (ref i31)))) |
47 |
| - (type $s1 (sub $q1 (array (ref i31)))) |
48 |
| - (type $s2 (sub $q2 (array (ref i31)))) |
| 31 | + (type $i31 (sub $eq (array i31ref))) |
| 32 | + (type $i31_2 (sub $i31 (array i31ref))) |
| 33 | + (type $i31_mut (sub (array (mut i31ref)))) |
| 34 | + (type $i31_mut_2 (sub $i31_mut (array (mut i31ref)))) |
49 | 35 |
|
50 | 36 | ;; array refs
|
51 |
| - (type $rr (sub $q (array arrayref))) |
52 |
| - (type $rr1 (sub $q1 (array arrayref))) |
53 |
| - (type $ss (sub $rr (array (ref array)))) |
54 |
| - (type $ss0 (sub $ss (array (ref $rr)))) |
55 |
| - (type $ss1 (sub $q1 (array (ref array)))) |
56 |
| - (type (sub $q1 (array (ref $rr)))) |
57 |
| - (type $ss2 (sub $q2 (array (ref array)))) |
58 |
| - (type (sub $q2 (array (ref $rr)))) |
| 37 | + (type $array (sub $eq (array arrayref))) |
| 38 | + (type $array_2 (sub $array (array arrayref))) |
| 39 | + (type $array_mut (sub (array (mut arrayref)))) |
| 40 | + (type $array_mut_2 (sub $array_mut (array (mut arrayref)))) |
| 41 | + |
| 42 | + ;; concrete array refs |
| 43 | + (type $concrete_array (sub $array (array (ref null $array)))) |
| 44 | + (type $concrete_array_2 (sub $concrete_array (array (ref null $array)))) |
| 45 | + (type $concrete_array_mut (sub (array (ref null $array_mut)))) |
| 46 | + (type $concrete_array_mut_2 (sub $concrete_array_mut (array (ref null $array_mut)))) |
59 | 47 |
|
60 | 48 | ;; struct refs
|
61 |
| - (type $rrr (sub $q (array structref))) |
62 |
| - (type $rrr1 (sub $q1 (array structref))) |
63 |
| - (type $sss (sub $rrr (array (ref struct)))) |
64 |
| - (type $sss0 (sub $rrr (array (ref null $d)))) |
65 |
| - (type $sss1 (sub $q1 (array (ref struct)))) |
66 |
| - (type (sub $q1 (array (ref $d)))) |
67 |
| - (type $sss2 (sub $q2 (array (ref struct)))) |
68 |
| - (type (sub $q2 (array (ref $d)))) |
| 49 | + (type $struct (sub $eq (array structref))) |
| 50 | + (type $struct_2 (sub $struct (array structref))) |
| 51 | + (type $struct_mut (sub (array (mut structref)))) |
| 52 | + (type $struct_mut_2 (sub $struct_mut (array (mut structref)))) |
| 53 | + |
| 54 | + ;; concrete struct refs |
| 55 | + (type $my_struct (struct)) |
| 56 | + (type $concrete_struct (sub $struct (array (ref null $my_struct)))) |
| 57 | + (type $concrete_struct_2 (sub $concrete_struct (array (ref null $my_struct)))) |
| 58 | + (type $concrete_struct_mut (sub (array (mut (ref null $my_struct))))) |
| 59 | + (type $concrete_struct_mut_2 (sub $concrete_struct_mut (array (mut (ref null $my_struct))))) |
69 | 60 |
|
70 | 61 | ;; none refs
|
71 |
| - (type $z1 (sub $q (array (mut nullref)))) |
72 |
| - (type $z2 (sub $q0 (array (ref none)))) |
73 |
| - (type $z3 (sub $z1 (array (mut (ref none))))) |
74 |
| - (type $z4 (sub $z1 (array nullref))) |
75 |
| - (type (sub $q1 (array nullref))) |
76 |
| - (type (sub $r (array nullref))) |
77 |
| - (type (sub $rr (array nullref))) |
78 |
| - (type (sub $rrr (array nullref))) |
79 |
| - (type (sub $q1 (array (ref none)))) |
80 |
| - (type (sub $r (array (ref none)))) |
81 |
| - (type (sub $rr (array (ref none)))) |
82 |
| - (type (sub $rrr (array (ref none)))) |
| 62 | + (type $none (sub (array nullref))) |
| 63 | + (type $none_2 (sub $none (array nullref))) |
| 64 | + (type $none_any (sub $any (array nullref))) |
| 65 | + (type $none_any_2 (sub $none_any (array nullref))) |
| 66 | + (type $none_eq (sub $eq (array nullref))) |
| 67 | + (type $none_eq_2 (sub $none_eq (array nullref))) |
| 68 | + (type $none_i31 (sub $i31 (array nullref))) |
| 69 | + (type $none_i31_2 (sub $none_i31 (array nullref))) |
| 70 | + (type $none_array (sub $array (array nullref))) |
| 71 | + (type $none_array_2 (sub $none_array (array nullref))) |
| 72 | + (type $none_concrete_array (sub $concrete_array (array nullref))) |
| 73 | + (type $none_concrete_array_2 (sub $none_concrete_array (array nullref))) |
| 74 | + (type $none_struct (sub $struct (array nullref))) |
| 75 | + (type $none_struct_2 (sub $none_struct (array nullref))) |
| 76 | + (type $none_concrete_struct (sub $concrete_struct (array nullref))) |
| 77 | + (type $none_concrete_struct_2 (sub $none_concrete_struct (array nullref))) |
| 78 | + (type $none_mut (sub (array (mut nullref)))) |
| 79 | + (type $none_mut_2 (sub $none_mut (array (mut nullref)))) |
83 | 80 |
|
84 | 81 | ;; func refs
|
85 |
| - (type $t (sub (array (mut funcref)))) |
86 |
| - (type $u (sub $t (array (ref null func)))) |
87 |
| - (type $v (sub $u (array (ref func)))) |
88 |
| - (type $w (sub $v (array (ref $a)))) |
89 |
| - (type $x (sub $t (array (ref null $a)))) |
90 |
| - (type $y (sub $w (array (ref nofunc)))) |
91 |
| - (type $z (sub $x (array nullfuncref))) |
| 82 | + (type $func (sub (array funcref))) |
| 83 | + (type $func_2 (sub $func (array funcref))) |
| 84 | + (type $func_mut (sub (array (mut funcref)))) |
| 85 | + (type $func_mut_2 (sub $func_mut (array (mut funcref)))) |
| 86 | + |
| 87 | + ;; concrete func refs |
| 88 | + (type $my_func (func)) |
| 89 | + (type $concrete_func (sub $func (array (ref null $my_func)))) |
| 90 | + (type $concrete_func_2 (sub $concrete_func (array (ref null $my_func)))) |
| 91 | + (type $concrete_func_mut (sub (array (mut (ref null $my_func))))) |
| 92 | + (type $concrete_func_mut_2 (sub $concrete_func_mut (array (mut (ref null $my_func))))) |
| 93 | + |
| 94 | + ;; nofunc |
| 95 | + (type $nofunc (sub $concrete_func (array nullfuncref))) |
| 96 | + (type $nofunc_2 (sub $nofunc (array nullfuncref))) |
| 97 | + (type $nofunc_mut (sub (array (mut nullfuncref)))) |
| 98 | + (type $nofunc_mut_2 (sub $nofunc_mut (array (mut nullfuncref)))) |
92 | 99 |
|
93 | 100 | ;; extern refs
|
94 |
| - (type $t0 (sub (array (mut externref)))) |
95 |
| - (type $u0 (sub $t0 (array (ref null extern)))) |
96 |
| - (type $v0 (sub $u0 (array (ref extern)))) |
97 |
| - (type $y0 (sub $v0 (array (ref noextern)))) |
98 |
| - (type $y01 (sub $u0 (array (ref noextern)))) |
99 |
| - (type $z0 (sub $u0 (array nullexternref))) |
100 |
| - |
101 |
| - (type $A (sub (struct (field $vt (mut i32))))) |
102 |
| - (type $B (sub $A (struct (field $vt (mut i32))))) |
103 |
| - (type (sub $A (struct (field $tv (mut i32))))) ;; same field, different name |
104 |
| - (type (sub $A (struct (field (mut i32)) (field $vt (mut i64))))) ;; different field, same name |
| 101 | + (type $extern (sub (array externref))) |
| 102 | + (type $extern_2 (sub $extern (array externref))) |
| 103 | + (type $extern_mut (sub (array (mut externref)))) |
| 104 | + (type $extern_mut_2 (sub $extern_mut (array (mut externref)))) |
| 105 | + |
| 106 | + ;; noextern |
| 107 | + (type $noextern (sub $extern (array nullexternref))) |
| 108 | + (type $noextern_2 (sub $noextern (array nullexternref))) |
| 109 | + (type $noextern_mut (sub (array (mut nullexternref)))) |
| 110 | + (type $noextern_mut_2 (sub $noextern_mut (array (mut nullexternref)))) |
| 111 | + |
| 112 | + ;; field names |
| 113 | + (type $struct_with_named_field (sub (struct (field $field (mut i32))))) |
| 114 | + ;; same field, same name |
| 115 | + (type (sub $struct_with_named_field (struct (field $field (mut i32))))) |
| 116 | + ;; same field, different name |
| 117 | + (type (sub $struct_with_named_field (struct (field $different (mut i32))))) |
| 118 | + ;; different field, same name |
| 119 | + (type (sub $struct_with_named_field (struct (field (mut i32)) (field $field (mut i64))))) |
105 | 120 | )
|
0 commit comments