| 1 |
;; RUN: wast --assert default,snapshot-folded --snapshot tests/snapshots % |
| 2 |
|
| 3 |
;; Test `return_call_indirect` operator |
| 4 |
|
| 5 |
(module |
| 6 |
;; Auxiliary definitions |
| 7 |
(type $proc (func)) |
| 8 |
(type $out-i32 (func (result i32))) |
| 9 |
(type $out-i64 (func (result i64))) |
| 10 |
(type $out-f32 (func (result f32))) |
| 11 |
(type $out-f64 (func (result f64))) |
| 12 |
(type $over-i32 (func (param i32) (result i32))) |
| 13 |
(type $over-i64 (func (param i64) (result i64))) |
| 14 |
(type $over-f32 (func (param f32) (result f32))) |
| 15 |
(type $over-f64 (func (param f64) (result f64))) |
| 16 |
(type $f32-i32 (func (param f32 i32) (result i32))) |
| 17 |
(type $i32-i64 (func (param i32 i64) (result i64))) |
| 18 |
(type $f64-f32 (func (param f64 f32) (result f32))) |
| 19 |
(type $i64-f64 (func (param i64 f64) (result f64))) |
| 20 |
(type $over-i32-duplicate (func (param i32) (result i32))) |
| 21 |
(type $over-i64-duplicate (func (param i64) (result i64))) |
| 22 |
(type $over-f32-duplicate (func (param f32) (result f32))) |
| 23 |
(type $over-f64-duplicate (func (param f64) (result f64))) |
| 24 |
|
| 25 |
(func $const-i32 (type $out-i32) (i32.const 0x132)) |
| 26 |
(func $const-i64 (type $out-i64) (i64.const 0x164)) |
| 27 |
(func $const-f32 (type $out-f32) (f32.const 0xf32)) |
| 28 |
(func $const-f64 (type $out-f64) (f64.const 0xf64)) |
| 29 |
|
| 30 |
(func $id-i32 (type $over-i32) (local.get 0)) |
| 31 |
(func $id-i64 (type $over-i64) (local.get 0)) |
| 32 |
(func $id-f32 (type $over-f32) (local.get 0)) |
| 33 |
(func $id-f64 (type $over-f64) (local.get 0)) |
| 34 |
|
| 35 |
(func $i32-i64 (type $i32-i64) (local.get 1)) |
| 36 |
(func $i64-f64 (type $i64-f64) (local.get 1)) |
| 37 |
(func $f32-i32 (type $f32-i32) (local.get 1)) |
| 38 |
(func $f64-f32 (type $f64-f32) (local.get 1)) |
| 39 |
|
| 40 |
(func $over-i32-duplicate (type $over-i32-duplicate) (local.get 0)) |
| 41 |
(func $over-i64-duplicate (type $over-i64-duplicate) (local.get 0)) |
| 42 |
(func $over-f32-duplicate (type $over-f32-duplicate) (local.get 0)) |
| 43 |
(func $over-f64-duplicate (type $over-f64-duplicate) (local.get 0)) |
| 44 |
|
| 45 |
(table funcref |
| 46 |
(elem |
| 47 |
$const-i32 $const-i64 $const-f32 $const-f64 |
| 48 |
$id-i32 $id-i64 $id-f32 $id-f64 |
| 49 |
$f32-i32 $i32-i64 $f64-f32 $i64-f64 |
| 50 |
$fac $fac-acc $even $odd |
| 51 |
$over-i32-duplicate $over-i64-duplicate |
| 52 |
$over-f32-duplicate $over-f64-duplicate |
| 53 |
) |
| 54 |
) |
| 55 |
|
| 56 |
;; Syntax |
| 57 |
|
| 58 |
(func |
| 59 |
(return_call_indirect (i32.const 0)) |
| 60 |
(return_call_indirect (param i64) (i64.const 0) (i32.const 0)) |
| 61 |
(return_call_indirect (param i64) (param) (param f64 i32 i64) |
| 62 |
(i64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (i32.const 0) |
| 63 |
) |
| 64 |
(return_call_indirect (result) (i32.const 0)) |
| 65 |
) |
| 66 |
|
| 67 |
(func (result i32) |
| 68 |
(return_call_indirect (result i32) (i32.const 0)) |
| 69 |
(return_call_indirect (result i32) (result) (i32.const 0)) |
| 70 |
(return_call_indirect (param i64) (result i32) (i64.const 0) (i32.const 0)) |
| 71 |
(return_call_indirect |
| 72 |
(param) (param i64) (param) (param f64 i32 i64) (param) (param) |
| 73 |
(result) (result i32) (result) (result) |
| 74 |
(i64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (i32.const 0) |
| 75 |
) |
| 76 |
) |
| 77 |
|
| 78 |
(func (result i64) |
| 79 |
(return_call_indirect (type $over-i64) (param i64) (result i64) |
| 80 |
(i64.const 0) (i32.const 0) |
| 81 |
) |
| 82 |
) |
| 83 |
|
| 84 |
;; Typing |
| 85 |
|
| 86 |
(func (export "type-i32") (result i32) |
| 87 |
(return_call_indirect (type $out-i32) (i32.const 0)) |
| 88 |
) |
| 89 |
(func (export "type-i64") (result i64) |
| 90 |
(return_call_indirect (type $out-i64) (i32.const 1)) |
| 91 |
) |
| 92 |
(func (export "type-f32") (result f32) |
| 93 |
(return_call_indirect (type $out-f32) (i32.const 2)) |
| 94 |
) |
| 95 |
(func (export "type-f64") (result f64) |
| 96 |
(return_call_indirect (type $out-f64) (i32.const 3)) |
| 97 |
) |
| 98 |
|
| 99 |
(func (export "type-index") (result i64) |
| 100 |
(return_call_indirect (type $over-i64) (i64.const 100) (i32.const 5)) |
| 101 |
) |
| 102 |
|
| 103 |
(func (export "type-first-i32") (result i32) |
| 104 |
(return_call_indirect (type $over-i32) (i32.const 32) (i32.const 4)) |
| 105 |
) |
| 106 |
(func (export "type-first-i64") (result i64) |
| 107 |
(return_call_indirect (type $over-i64) (i64.const 64) (i32.const 5)) |
| 108 |
) |
| 109 |
(func (export "type-first-f32") (result f32) |
| 110 |
(return_call_indirect (type $over-f32) (f32.const 1.32) (i32.const 6)) |
| 111 |
) |
| 112 |
(func (export "type-first-f64") (result f64) |
| 113 |
(return_call_indirect (type $over-f64) (f64.const 1.64) (i32.const 7)) |
| 114 |
) |
| 115 |
|
| 116 |
(func (export "type-second-i32") (result i32) |
| 117 |
(return_call_indirect (type $f32-i32) |
| 118 |
(f32.const 32.1) (i32.const 32) (i32.const 8) |
| 119 |
) |
| 120 |
) |
| 121 |
(func (export "type-second-i64") (result i64) |
| 122 |
(return_call_indirect (type $i32-i64) |
| 123 |
(i32.const 32) (i64.const 64) (i32.const 9) |
| 124 |
) |
| 125 |
) |
| 126 |
(func (export "type-second-f32") (result f32) |
| 127 |
(return_call_indirect (type $f64-f32) |
| 128 |
(f64.const 64) (f32.const 32) (i32.const 10) |
| 129 |
) |
| 130 |
) |
| 131 |
(func (export "type-second-f64") (result f64) |
| 132 |
(return_call_indirect (type $i64-f64) |
| 133 |
(i64.const 64) (f64.const 64.1) (i32.const 11) |
| 134 |
) |
| 135 |
) |
| 136 |
|
| 137 |
;; Dispatch |
| 138 |
|
| 139 |
(func (export "dispatch") (param i32 i64) (result i64) |
| 140 |
(return_call_indirect (type $over-i64) (local.get 1) (local.get 0)) |
| 141 |
) |
| 142 |
|
| 143 |
(func (export "dispatch-structural") (param i32) (result i64) |
| 144 |
(return_call_indirect (type $over-i64-duplicate) |
| 145 |
(i64.const 9) (local.get 0) |
| 146 |
) |
| 147 |
) |
| 148 |
|
| 149 |
;; Multiple tables |
| 150 |
|
| 151 |
(table $tab2 funcref (elem $tab-f1)) |
| 152 |
(table $tab3 funcref (elem $tab-f2)) |
| 153 |
|
| 154 |
(func $tab-f1 (result i32) (i32.const 0x133)) |
| 155 |
(func $tab-f2 (result i32) (i32.const 0x134)) |
| 156 |
|
| 157 |
(func (export "call-tab") (param $i i32) (result i32) |
| 158 |
(if (i32.eq (local.get $i) (i32.const 0)) |
| 159 |
(then (return_call_indirect (type $out-i32) (i32.const 0))) |
| 160 |
) |
| 161 |
(if (i32.eq (local.get $i) (i32.const 1)) |
| 162 |
(then (return_call_indirect 1 (type $out-i32) (i32.const 0))) |
| 163 |
) |
| 164 |
(if (i32.eq (local.get $i) (i32.const 2)) |
| 165 |
(then (return_call_indirect $tab3 (type $out-i32) (i32.const 0))) |
| 166 |
) |
| 167 |
(i32.const 0) |
| 168 |
) |
| 169 |
|
| 170 |
;; Recursion |
| 171 |
|
| 172 |
(func $fac (export "fac") (type $over-i64) |
| 173 |
(return_call_indirect (param i64 i64) (result i64) |
| 174 |
(local.get 0) (i64.const 1) (i32.const 13) |
| 175 |
) |
| 176 |
) |
| 177 |
|
| 178 |
(func $fac-acc (param i64 i64) (result i64) |
| 179 |
(if (result i64) (i64.eqz (local.get 0)) |
| 180 |
(then (local.get 1)) |
| 181 |
(else |
| 182 |
(return_call_indirect (param i64 i64) (result i64) |
| 183 |
(i64.sub (local.get 0) (i64.const 1)) |
| 184 |
(i64.mul (local.get 0) (local.get 1)) |
| 185 |
(i32.const 13) |
| 186 |
) |
| 187 |
) |
| 188 |
) |
| 189 |
) |
| 190 |
|
| 191 |
(func $even (export "even") (param i32) (result i32) |
| 192 |
(if (result i32) (i32.eqz (local.get 0)) |
| 193 |
(then (i32.const 44)) |
| 194 |
(else |
| 195 |
(return_call_indirect (type $over-i32) |
| 196 |
(i32.sub (local.get 0) (i32.const 1)) |
| 197 |
(i32.const 15) |
| 198 |
) |
| 199 |
) |
| 200 |
) |
| 201 |
) |
| 202 |
(func $odd (export "odd") (param i32) (result i32) |
| 203 |
(if (result i32) (i32.eqz (local.get 0)) |
| 204 |
(then (i32.const 99)) |
| 205 |
(else |
| 206 |
(return_call_indirect (type $over-i32) |
| 207 |
(i32.sub (local.get 0) (i32.const 1)) |
| 208 |
(i32.const 14) |
| 209 |
) |
| 210 |
) |
| 211 |
) |
| 212 |
) |
| 213 |
) |
| 214 |
|
| 215 |
(assert_return (invoke "type-i32") (i32.const 0x132)) |
| 216 |
(assert_return (invoke "type-i64") (i64.const 0x164)) |
| 217 |
(assert_return (invoke "type-f32") (f32.const 0xf32)) |
| 218 |
(assert_return (invoke "type-f64") (f64.const 0xf64)) |
| 219 |
|
| 220 |
(assert_return (invoke "type-index") (i64.const 100)) |
| 221 |
|
| 222 |
(assert_return (invoke "type-first-i32") (i32.const 32)) |
| 223 |
(assert_return (invoke "type-first-i64") (i64.const 64)) |
| 224 |
(assert_return (invoke "type-first-f32") (f32.const 1.32)) |
| 225 |
(assert_return (invoke "type-first-f64") (f64.const 1.64)) |
| 226 |
|
| 227 |
(assert_return (invoke "type-second-i32") (i32.const 32)) |
| 228 |
(assert_return (invoke "type-second-i64") (i64.const 64)) |
| 229 |
(assert_return (invoke "type-second-f32") (f32.const 32)) |
| 230 |
(assert_return (invoke "type-second-f64") (f64.const 64.1)) |
| 231 |
|
| 232 |
(assert_return (invoke "dispatch" (i32.const 5) (i64.const 2)) (i64.const 2)) |
| 233 |
(assert_return (invoke "dispatch" (i32.const 5) (i64.const 5)) (i64.const 5)) |
| 234 |
(assert_return (invoke "dispatch" (i32.const 12) (i64.const 5)) (i64.const 120)) |
| 235 |
(assert_return (invoke "dispatch" (i32.const 17) (i64.const 2)) (i64.const 2)) |
| 236 |
(assert_trap (invoke "dispatch" (i32.const 0) (i64.const 2)) "indirect call type mismatch") |
| 237 |
(assert_trap (invoke "dispatch" (i32.const 15) (i64.const 2)) "indirect call type mismatch") |
| 238 |
(assert_trap (invoke "dispatch" (i32.const 20) (i64.const 2)) "undefined element") |
| 239 |
(assert_trap (invoke "dispatch" (i32.const -1) (i64.const 2)) "undefined element") |
| 240 |
(assert_trap (invoke "dispatch" (i32.const 1213432423) (i64.const 2)) "undefined element") |
| 241 |
|
| 242 |
(assert_return (invoke "dispatch-structural" (i32.const 5)) (i64.const 9)) |
| 243 |
(assert_return (invoke "dispatch-structural" (i32.const 5)) (i64.const 9)) |
| 244 |
(assert_return (invoke "dispatch-structural" (i32.const 12)) (i64.const 362880)) |
| 245 |
(assert_return (invoke "dispatch-structural" (i32.const 17)) (i64.const 9)) |
| 246 |
(assert_trap (invoke "dispatch-structural" (i32.const 11)) "indirect call type mismatch") |
| 247 |
(assert_trap (invoke "dispatch-structural" (i32.const 16)) "indirect call type mismatch") |
| 248 |
|
| 249 |
(assert_return (invoke "call-tab" (i32.const 0)) (i32.const 0x132)) |
| 250 |
(assert_return (invoke "call-tab" (i32.const 1)) (i32.const 0x133)) |
| 251 |
(assert_return (invoke "call-tab" (i32.const 2)) (i32.const 0x134)) |
| 252 |
|
| 253 |
(assert_return (invoke "fac" (i64.const 0)) (i64.const 1)) |
| 254 |
(assert_return (invoke "fac" (i64.const 1)) (i64.const 1)) |
| 255 |
(assert_return (invoke "fac" (i64.const 5)) (i64.const 120)) |
| 256 |
(assert_return (invoke "fac" (i64.const 25)) (i64.const 7034535277573963776)) |
| 257 |
|
| 258 |
(assert_return (invoke "even" (i32.const 0)) (i32.const 44)) |
| 259 |
(assert_return (invoke "even" (i32.const 1)) (i32.const 99)) |
| 260 |
(assert_return (invoke "even" (i32.const 100)) (i32.const 44)) |
| 261 |
(assert_return (invoke "even" (i32.const 77)) (i32.const 99)) |
| 262 |
(assert_return (invoke "even" (i32.const 100_000)) (i32.const 44)) |
| 263 |
(assert_return (invoke "even" (i32.const 111_111)) (i32.const 99)) |
| 264 |
(assert_return (invoke "odd" (i32.const 0)) (i32.const 99)) |
| 265 |
(assert_return (invoke "odd" (i32.const 1)) (i32.const 44)) |
| 266 |
(assert_return (invoke "odd" (i32.const 200)) (i32.const 99)) |
| 267 |
(assert_return (invoke "odd" (i32.const 77)) (i32.const 44)) |
| 268 |
(assert_return (invoke "odd" (i32.const 200_002)) (i32.const 99)) |
| 269 |
(assert_return (invoke "odd" (i32.const 300_003)) (i32.const 44)) |
| 270 |
|
| 271 |
|
| 272 |
;; Invalid syntax |
| 273 |
|
| 274 |
(assert_malformed |
| 275 |
(module quote |
| 276 |
"(type $sig (func (param i32) (result i32)))" |
| 277 |
"(table 0 funcref)" |
| 278 |
"(func (result i32)" |
| 279 |
" (return_call_indirect (type $sig) (result i32) (param i32)" |
| 280 |
" (i32.const 0) (i32.const 0)" |
| 281 |
" )" |
| 282 |
")" |
| 283 |
) |
| 284 |
"unexpected token" |
| 285 |
) |
| 286 |
(assert_malformed |
| 287 |
(module quote |
| 288 |
"(type $sig (func (param i32) (result i32)))" |
| 289 |
"(table 0 funcref)" |
| 290 |
"(func (result i32)" |
| 291 |
" (return_call_indirect (param i32) (type $sig) (result i32)" |
| 292 |
" (i32.const 0) (i32.const 0)" |
| 293 |
" )" |
| 294 |
")" |
| 295 |
) |
| 296 |
"unexpected token" |
| 297 |
) |
| 298 |
(assert_malformed |
| 299 |
(module quote |
| 300 |
"(type $sig (func (param i32) (result i32)))" |
| 301 |
"(table 0 funcref)" |
| 302 |
"(func (result i32)" |
| 303 |
" (return_call_indirect (param i32) (result i32) (type $sig)" |
| 304 |
" (i32.const 0) (i32.const 0)" |
| 305 |
" )" |
| 306 |
")" |
| 307 |
) |
| 308 |
"unexpected token" |
| 309 |
) |
| 310 |
(assert_malformed |
| 311 |
(module quote |
| 312 |
"(type $sig (func (param i32) (result i32)))" |
| 313 |
"(table 0 funcref)" |
| 314 |
"(func (result i32)" |
| 315 |
" (return_call_indirect (result i32) (type $sig) (param i32)" |
| 316 |
" (i32.const 0) (i32.const 0)" |
| 317 |
" )" |
| 318 |
")" |
| 319 |
) |
| 320 |
"unexpected token" |
| 321 |
) |
| 322 |
(assert_malformed |
| 323 |
(module quote |
| 324 |
"(type $sig (func (param i32) (result i32)))" |
| 325 |
"(table 0 funcref)" |
| 326 |
"(func (result i32)" |
| 327 |
" (return_call_indirect (result i32) (param i32) (type $sig)" |
| 328 |
" (i32.const 0) (i32.const 0)" |
| 329 |
" )" |
| 330 |
")" |
| 331 |
) |
| 332 |
"unexpected token" |
| 333 |
) |
| 334 |
(assert_malformed |
| 335 |
(module quote |
| 336 |
"(table 0 funcref)" |
| 337 |
"(func (result i32)" |
| 338 |
" (return_call_indirect (result i32) (param i32)" |
| 339 |
" (i32.const 0) (i32.const 0)" |
| 340 |
" )" |
| 341 |
")" |
| 342 |
) |
| 343 |
"unexpected token" |
| 344 |
) |
| 345 |
|
| 346 |
(assert_malformed |
| 347 |
(module quote |
| 348 |
"(table 0 funcref)" |
| 349 |
"(func (return_call_indirect (param $x i32) (i32.const 0) (i32.const 0)))" |
| 350 |
) |
| 351 |
"unexpected token" |
| 352 |
) |
| 353 |
(assert_malformed |
| 354 |
(module quote |
| 355 |
"(type $sig (func))" |
| 356 |
"(table 0 funcref)" |
| 357 |
"(func (result i32)" |
| 358 |
" (return_call_indirect (type $sig) (result i32) (i32.const 0))" |
| 359 |
")" |
| 360 |
) |
| 361 |
"inline function type" |
| 362 |
) |
| 363 |
(assert_malformed |
| 364 |
(module quote |
| 365 |
"(type $sig (func (param i32) (result i32)))" |
| 366 |
"(table 0 funcref)" |
| 367 |
"(func (result i32)" |
| 368 |
" (return_call_indirect (type $sig) (result i32) (i32.const 0))" |
| 369 |
")" |
| 370 |
) |
| 371 |
"inline function type" |
| 372 |
) |
| 373 |
(assert_malformed |
| 374 |
(module quote |
| 375 |
"(type $sig (func (param i32) (result i32)))" |
| 376 |
"(table 0 funcref)" |
| 377 |
"(func" |
| 378 |
" (return_call_indirect (type $sig) (param i32)" |
| 379 |
" (i32.const 0) (i32.const 0)" |
| 380 |
" )" |
| 381 |
")" |
| 382 |
) |
| 383 |
"inline function type" |
| 384 |
) |
| 385 |
(assert_malformed |
| 386 |
(module quote |
| 387 |
"(type $sig (func (param i32 i32) (result i32)))" |
| 388 |
"(table 0 funcref)" |
| 389 |
"(func (result i32)" |
| 390 |
" (return_call_indirect (type $sig) (param i32) (result i32)" |
| 391 |
" (i32.const 0) (i32.const 0)" |
| 392 |
" )" |
| 393 |
")" |
| 394 |
) |
| 395 |
"inline function type" |
| 396 |
) |
| 397 |
|
| 398 |
;; Invalid typing |
| 399 |
|
| 400 |
(assert_invalid |
| 401 |
(module |
| 402 |
(type (func)) |
| 403 |
(func $no-table (return_call_indirect (type 0) (i32.const 0))) |
| 404 |
) |
| 405 |
"unknown table" |
| 406 |
) |
| 407 |
|
| 408 |
(assert_invalid |
| 409 |
(module |
| 410 |
(type (func)) |
| 411 |
(table 0 funcref) |
| 412 |
(func $type-void-vs-num (i32.eqz (return_call_indirect (type 0) (i32.const 0)))) |
| 413 |
) |
| 414 |
"type mismatch" |
| 415 |
) |
| 416 |
(assert_invalid |
| 417 |
(module |
| 418 |
(type (func (result i64))) |
| 419 |
(table 0 funcref) |
| 420 |
(func $type-num-vs-num (i32.eqz (return_call_indirect (type 0) (i32.const 0)))) |
| 421 |
) |
| 422 |
"type mismatch" |
| 423 |
) |
| 424 |
|
| 425 |
(assert_invalid |
| 426 |
(module |
| 427 |
(type (func (param i32))) |
| 428 |
(table 0 funcref) |
| 429 |
(func $arity-0-vs-1 (return_call_indirect (type 0) (i32.const 0))) |
| 430 |
) |
| 431 |
"type mismatch" |
| 432 |
) |
| 433 |
(assert_invalid |
| 434 |
(module |
| 435 |
(type (func (param f64 i32))) |
| 436 |
(table 0 funcref) |
| 437 |
(func $arity-0-vs-2 (return_call_indirect (type 0) (i32.const 0))) |
| 438 |
) |
| 439 |
"type mismatch" |
| 440 |
) |
| 441 |
|
| 442 |
(module |
| 443 |
(type (func)) |
| 444 |
(table 0 funcref) |
| 445 |
(func $arity-1-vs-0 (return_call_indirect (type 0) (i32.const 1) (i32.const 0))) |
| 446 |
) |
| 447 |
|
| 448 |
(module |
| 449 |
(type (func)) |
| 450 |
(table 0 funcref) |
| 451 |
(func $arity-2-vs-0 |
| 452 |
(return_call_indirect (type 0) (f64.const 2) (i32.const 1) (i32.const 0)) |
| 453 |
) |
| 454 |
) |
| 455 |
|
| 456 |
(assert_invalid |
| 457 |
(module |
| 458 |
(type (func (param i32))) |
| 459 |
(table 0 funcref) |
| 460 |
(func $type-func-void-vs-i32 (return_call_indirect (type 0) (i32.const 1) (nop))) |
| 461 |
) |
| 462 |
"type mismatch" |
| 463 |
) |
| 464 |
(assert_invalid |
| 465 |
(module |
| 466 |
(type (func (param i32))) |
| 467 |
(table 0 funcref) |
| 468 |
(func $type-func-num-vs-i32 (return_call_indirect (type 0) (i32.const 0) (i64.const 1))) |
| 469 |
) |
| 470 |
"type mismatch" |
| 471 |
) |
| 472 |
|
| 473 |
(assert_invalid |
| 474 |
(module |
| 475 |
(type (func (param i32 i32))) |
| 476 |
(table 0 funcref) |
| 477 |
(func $type-first-void-vs-num |
| 478 |
(return_call_indirect (type 0) (nop) (i32.const 1) (i32.const 0)) |
| 479 |
) |
| 480 |
) |
| 481 |
"type mismatch" |
| 482 |
) |
| 483 |
(assert_invalid |
| 484 |
(module |
| 485 |
(type (func (param i32 i32))) |
| 486 |
(table 0 funcref) |
| 487 |
(func $type-second-void-vs-num |
| 488 |
(return_call_indirect (type 0) (i32.const 1) (nop) (i32.const 0)) |
| 489 |
) |
| 490 |
) |
| 491 |
"type mismatch" |
| 492 |
) |
| 493 |
(assert_invalid |
| 494 |
(module |
| 495 |
(type (func (param i32 f64))) |
| 496 |
(table 0 funcref) |
| 497 |
(func $type-first-num-vs-num |
| 498 |
(return_call_indirect (type 0) (f64.const 1) (i32.const 1) (i32.const 0)) |
| 499 |
) |
| 500 |
) |
| 501 |
"type mismatch" |
| 502 |
) |
| 503 |
(assert_invalid |
| 504 |
(module |
| 505 |
(type (func (param f64 i32))) |
| 506 |
(table 0 funcref) |
| 507 |
(func $type-second-num-vs-num |
| 508 |
(return_call_indirect (type 0) (i32.const 1) (f64.const 1) (i32.const 0)) |
| 509 |
) |
| 510 |
) |
| 511 |
"type mismatch" |
| 512 |
) |
| 513 |
(assert_invalid |
| 514 |
(module |
| 515 |
(type $ty (func (result i32 i32))) |
| 516 |
(import "env" "table" (table $table 0 funcref)) |
| 517 |
(func (param i32) (result i32) |
| 518 |
local.get 0 |
| 519 |
return_call_indirect $table (type $ty) |
| 520 |
) |
| 521 |
) |
| 522 |
"type mismatch" |
| 523 |
) |
| 524 |
|
| 525 |
;; Unbound type |
| 526 |
|
| 527 |
(assert_invalid |
| 528 |
(module |
| 529 |
(table 0 funcref) |
| 530 |
(func $unbound-type (return_call_indirect (type 1) (i32.const 0))) |
| 531 |
) |
| 532 |
"unknown type" |
| 533 |
) |
| 534 |
(assert_invalid |
| 535 |
(module |
| 536 |
(table 0 funcref) |
| 537 |
(func $large-type (return_call_indirect (type 1012321300) (i32.const 0))) |
| 538 |
) |
| 539 |
"unknown type" |
| 540 |
) |
| 541 |
|
| 542 |
|
| 543 |
;; Unbound function in table |
| 544 |
|
| 545 |
(assert_invalid |
| 546 |
(module (table funcref (elem 0 0))) |
| 547 |
"unknown function 0" |
| 548 |
) |