Skip to content

Commit

Permalink
Merge branch 'funcref'
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg committed Jul 3, 2024
2 parents 48158db + 9660b28 commit 796c528
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions proposals/function-references/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Typed references have no canonical default value, because they cannot be null. T
The function `$hof` takes a function pointer as parameter, and is invoked by `$caller`, passing `$inc` as argument:
```wasm
(type $i32-i32 (func (param i32) (result i32)))
(elem declare funcref (ref.func $inc))
(func $hof (param $f (ref $i32-i32)) (result i32)
(i32.add (i32.const 10) (call_ref $i32-i32 (i32.const 42) (local.get $f)))
Expand Down
10 changes: 9 additions & 1 deletion test/core/return_call.wast
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,15 @@
)
"type mismatch"
)

(assert_invalid
(module
(func $f (result i32 i32) unreachable)
(func (result i32)
return_call $f
)
)
"type mismatch"
)

;; Unbound function

Expand Down
12 changes: 11 additions & 1 deletion test/core/return_call_indirect.wast
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,17 @@
)
"type mismatch"
)

(assert_invalid
(module
(type $ty (func (result i32 i32)))
(import "env" "table" (table $table 0 funcref))
(func (param i32) (result i32)
local.get 0
return_call_indirect $table (type $ty)
)
)
"type mismatch"
)

;; Unbound type

Expand Down
11 changes: 11 additions & 0 deletions test/core/return_call_ref.wast
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,14 @@
)
"type mismatch"
)

(assert_invalid
(module
(type $ty (func (result i32 i32)))
(func (param funcref) (result i32)
local.get 0
return_call_ref $ty
)
)
"type mismatch"
)

0 comments on commit 796c528

Please sign in to comment.