diff --git a/interpreter/valid/match.ml b/interpreter/valid/match.ml index 4c5162e8..5f28af71 100644 --- a/interpreter/valid/match.ml +++ b/interpreter/valid/match.ml @@ -36,9 +36,6 @@ and eq_val_type t1 t2 = | BotT, BotT -> true | _, _ -> false -(* and eq_var_type t1 t2 = - * t1 = t2 *) - and eq_result_type ts1 ts2 = List.length ts1 = List.length ts2 && List.for_all2 eq_val_type ts1 ts2 @@ -148,9 +145,6 @@ and match_global_type (GlobalT (mut1, t1)) (GlobalT (mut2, t2)) = and match_tag_type (TagT ht1) (TagT ht2) = match_heap_type ht1 ht2 -(* and match_var_type t1 t2 = - * eq_var_type t1 t2 *) - let match_extern_type et1 et2 = match et1, et2 with | ExternFuncT ft1, ExternFuncT ft2 -> match_func_type ft1 ft2 diff --git a/interpreter/valid/valid.ml b/interpreter/valid/valid.ml index 6cf8bf9a..e5f91249 100644 --- a/interpreter/valid/valid.ml +++ b/interpreter/valid/valid.ml @@ -894,6 +894,7 @@ let check_tag (c : context) (tag : tag) : context = {c with tags = c.tags @ [tag']} + (* Modules *) let check_type (c : context) (ty : type_) : context = @@ -919,7 +920,6 @@ let check_import (c : context) (im : import) : context = let et = check_tag_type c (TagT (VarHT (StatX x.it))) idesc.at in {c with tags = c.tags @ [et]} - module NameSet = Set.Make(struct type t = Ast.name let compare = compare end) let check_export (c : context) (set : NameSet.t) (ex : export) : NameSet.t = diff --git a/test/core/table.wast b/test/core/table.wast index 1142c784..91801624 100644 --- a/test/core/table.wast +++ b/test/core/table.wast @@ -78,21 +78,61 @@ ;; Table initializer (module + (global (export "g") (ref $f) (ref.func $f)) + (type $f (func)) + (func $f) +) +(register "M") + +(module + (global $g (import "M" "g") (ref $dummy)) + (type $dummy (func)) (func $dummy) (table $t1 10 funcref) (table $t2 10 funcref (ref.func $dummy)) (table $t3 10 (ref $dummy) (ref.func $dummy)) + (table $t4 10 funcref (global.get $g)) + (table $t5 10 (ref $dummy) (global.get $g)) (func (export "get1") (result funcref) (table.get $t1 (i32.const 1))) (func (export "get2") (result funcref) (table.get $t2 (i32.const 4))) (func (export "get3") (result funcref) (table.get $t3 (i32.const 7))) + (func (export "get4") (result funcref) (table.get $t4 (i32.const 8))) + (func (export "get5") (result funcref) (table.get $t5 (i32.const 9))) ) (assert_return (invoke "get1") (ref.null)) (assert_return (invoke "get2") (ref.func)) (assert_return (invoke "get3") (ref.func)) +(assert_return (invoke "get4") (ref.func)) +(assert_return (invoke "get5") (ref.func)) + + +(assert_invalid + (module + (type $f (func)) + (table 10 (ref $f)) + ) + "type mismatch" +) + +(assert_invalid + (module + (type $f (func)) + (table 0 (ref $f)) + ) + "type mismatch" +) + +(assert_invalid + (module + (type $f (func)) + (table 0 0 (ref $f)) + ) + "type mismatch" +) (assert_invalid