| 1 |
;; RUN: wast % |
| 2 |
|
| 3 |
;; --enable-gc |
| 4 |
|
| 5 |
(assert_invalid |
| 6 |
(module |
| 7 |
(type $a (func)) |
| 8 |
(type $b (sub $a (func))) ;; invalid |
| 9 |
) |
| 10 |
"sub type cannot have a final super type" |
| 11 |
) |
| 12 |
(assert_invalid |
| 13 |
(module |
| 14 |
(type $a (sub (func))) |
| 15 |
(type $b (sub final $a (func))) |
| 16 |
(type $c (sub $b (func))) ;; invalid |
| 17 |
) |
| 18 |
"sub type cannot have a final super type" |
| 19 |
) |
| 20 |
(assert_invalid |
| 21 |
(module |
| 22 |
(type $a (sub (func))) |
| 23 |
(type $b (sub $a (struct))) ;; invalid |
| 24 |
) |
| 25 |
"sub type must match super type" |
| 26 |
) |
| 27 |
(assert_invalid |
| 28 |
(module |
| 29 |
(type $a (sub (func))) |
| 30 |
(type $b (sub $a (func (param i32)))) ;; invalid |
| 31 |
) |
| 32 |
"sub type must match super type" |
| 33 |
) |
| 34 |
(assert_invalid |
| 35 |
(module |
| 36 |
(type $a (sub (struct (field i32)))) |
| 37 |
(type $b (sub $a (struct (field i64)))) ;; invalid |
| 38 |
) |
| 39 |
"sub type must match super type" |
| 40 |
) |
| 41 |
(assert_invalid |
| 42 |
(module |
| 43 |
(type $d (sub (struct))) |
| 44 |
(type $e (sub $d (struct (field (ref null $d))))) |
| 45 |
(type $f (sub $e (struct (field (ref $e))))) |
| 46 |
|
| 47 |
(type $g (sub (func (param (ref $e)) (result (ref $e))))) |
| 48 |
(type $i (sub $g (func (param (ref $f)) (result (ref $d))))) ;; invalid |
| 49 |
) |
| 50 |
"sub type must match super type" |
| 51 |
) |
| 52 |
(assert_invalid |
| 53 |
(module |
| 54 |
(type $o (sub (array i32))) |
| 55 |
(type (sub $o (array (mut i32)))) ;; invalid |
| 56 |
) |
| 57 |
"sub type must match super type" |
| 58 |
) |
| 59 |
(assert_invalid |
| 60 |
(module |
| 61 |
(type $o (sub (array i32))) |
| 62 |
(type (sub $o (array i64))) ;; invalid |
| 63 |
) |
| 64 |
"sub type must match super type" |
| 65 |
) |
| 66 |
(assert_invalid |
| 67 |
(module |
| 68 |
(type $q (sub (array (mut anyref)))) |
| 69 |
(type $r (sub $q (array i31ref))) |
| 70 |
(type $s (sub $r (array (ref i31)))) |
| 71 |
(type (sub $s (array (ref null i31)))) ;; invalid |
| 72 |
) |
| 73 |
"sub type must match super type" |
| 74 |
) |
| 75 |
(assert_invalid |
| 76 |
(module |
| 77 |
(type $q (sub (array (mut anyref)))) |
| 78 |
(type $rr (sub $q (array arrayref))) |
| 79 |
(type $ss (sub $rr (array (ref array)))) |
| 80 |
(type (sub $ss (array (ref null array)))) ;; invalid |
| 81 |
) |
| 82 |
"sub type must match super type" |
| 83 |
) |
| 84 |
(assert_invalid |
| 85 |
(module |
| 86 |
(type $q (sub (array (mut anyref)))) |
| 87 |
(type $rrr (sub $q (array structref))) |
| 88 |
(type $sss (sub $rrr (array (ref struct)))) |
| 89 |
(type (sub $sss (array (ref null struct)))) ;; invalid |
| 90 |
) |
| 91 |
"sub type must match super type" |
| 92 |
) |
| 93 |
(assert_invalid |
| 94 |
(module |
| 95 |
(type $t (sub (array (mut funcref)))) |
| 96 |
(type $u (sub $t (array (ref null func)))) |
| 97 |
(type (sub $u (array (mut (ref func))))) ;; invalid |
| 98 |
) |
| 99 |
"sub type must match super type" |
| 100 |
) |
| 101 |
(assert_invalid |
| 102 |
(module |
| 103 |
(type $t (sub (array (mut funcref)))) |
| 104 |
(type $u (sub $t (array (ref null func)))) |
| 105 |
(type (sub $u (array (ref null extern)))) ;; invalid |
| 106 |
) |
| 107 |
"sub type must match super type" |
| 108 |
) |
| 109 |
(assert_invalid |
| 110 |
(module |
| 111 |
(type $t0 (sub (array (mut externref)))) |
| 112 |
(type $u0 (sub $t0 (array (ref null extern)))) |
| 113 |
(type (sub $u0 (array (mut (ref extern))))) ;; invalid |
| 114 |
) |
| 115 |
"sub type must match super type" |
| 116 |
) |
| 117 |
(assert_invalid |
| 118 |
(module |
| 119 |
(type $t0 (sub (array (mut externref)))) |
| 120 |
(type $u0 (sub $t0 (array (ref null extern)))) |
| 121 |
(type $v0 (sub $u0 (array (ref extern)))) |
| 122 |
(type (sub $v0 (array nullexternref))) ;; invalid |
| 123 |
) |
| 124 |
"sub type must match super type" |
| 125 |
) |
| 126 |
(assert_invalid |
| 127 |
(module |
| 128 |
(type $t (sub (array (mut funcref)))) |
| 129 |
(type (sub $t (array nullexternref))) ;; invalid |
| 130 |
) |
| 131 |
"sub type must match super type" |
| 132 |
) |
| 133 |
(assert_invalid |
| 134 |
(module |
| 135 |
(type $d (sub (struct))) |
| 136 |
(type $e (sub $d (struct (field (ref null $d))))) |
| 137 |
(type (sub $e (struct (field (ref 1000))))) |
| 138 |
) |
| 139 |
"type index out of bounds" |
| 140 |
) |
| 141 |
(assert_malformed |
| 142 |
(module quote |
| 143 |
"(type (struct (field $vt (mut i32)) (field $vt (mut i64))))" |
| 144 |
) |
| 145 |
"duplicate identifier" |
| 146 |
) |
| 147 |
(assert_invalid |
| 148 |
(module |
| 149 |
(type $a (func)) ;; types without `(sub )` are considered final |
| 150 |
(type (sub $a (func))) |
| 151 |
) |
| 152 |
"sub type cannot have a final super type" |
| 153 |
) |