1(module
2  (table $t1 2 funcref)
3  (elem (table $t1) (i32.const 0) func $nop)
4  (func $nop)
5
6  (func (export "t1") (param i32)
7    local.get 0
8    call_indirect $t1)
9  (func (export "t1-wrong-type") (param i32)
10    i32.const 0
11    local.get 0
12    call_indirect $t1 (param i32))
13
14  (type $empty (func))
15  (table $t2 2 (ref null $empty))
16  (elem (table $t2) (i32.const 0) (ref null $empty) (ref.func $nop))
17
18  (func (export "t2") (param i32)
19    local.get 0
20    call_indirect $t2)
21  (func (export "t2-wrong-type") (param i32)
22    i32.const 0
23    local.get 0
24    call_indirect $t2 (param i32))
25
26  (table $t3 2 (ref $empty) (ref.func $nop))
27
28  (func (export "t3") (param i32)
29    local.get 0
30    call_indirect $t3)
31  (func (export "t3-wrong-type") (param i32)
32    i32.const 0
33    local.get 0
34    call_indirect $t3 (param i32))
35)
36
37(assert_return (invoke "t1" (i32.const 0)))
38(assert_trap (invoke "t1" (i32.const 1)) "uninitialized element")
39(assert_trap (invoke "t1" (i32.const 2)) "out of bounds")
40(assert_trap (invoke "t1-wrong-type" (i32.const 0)) "call type mismatch")
41(assert_trap (invoke "t1-wrong-type" (i32.const 1)) "uninitialized element")
42(assert_trap (invoke "t1-wrong-type" (i32.const 2)) "out of bounds")
43(assert_return (invoke "t2" (i32.const 0)))
44(assert_trap (invoke "t2" (i32.const 1)) "uninitialized element")
45(assert_trap (invoke "t2" (i32.const 2)) "out of bounds")
46(assert_trap (invoke "t2-wrong-type" (i32.const 0)) "call type mismatch")
47(assert_trap (invoke "t2-wrong-type" (i32.const 1)) "uninitialized element")
48(assert_trap (invoke "t2-wrong-type" (i32.const 2)) "out of bounds")
49(assert_return (invoke "t3" (i32.const 0)))
50(assert_return (invoke "t3" (i32.const 1)))
51(assert_trap (invoke "t3" (i32.const 2)) "out of bounds")
52(assert_trap (invoke "t3-wrong-type" (i32.const 0)) "call type mismatch")
53(assert_trap (invoke "t3-wrong-type" (i32.const 1)) "call type mismatch")
54(assert_trap (invoke "t3-wrong-type" (i32.const 2)) "out of bounds")
55