Skip to content

Commit

Permalink
Merge branch 'main' of github.com:WebAssembly/function-references int…
Browse files Browse the repository at this point in the history
…o funcref-merge
  • Loading branch information
dhil committed Sep 21, 2023
2 parents af789d0 + 0b559e9 commit 1b8e62a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
6 changes: 0 additions & 6 deletions interpreter/valid/match.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion interpreter/valid/valid.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 =
Expand Down
40 changes: 40 additions & 0 deletions test/core/table.wast
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1b8e62a

Please sign in to comment.