Closed oovm closed 3 months ago
Thanks for the report! The example you're copying in the function-references proposal, and the snippet here, are both invalid and need to be updated (at least in the function-references proposal). The validation of ref.func
requires that the referenced function is already registered in an elem
segment or defined global. For this you'll want to do something like:
(elem declare funcref (ref.func $inc))
where the complete example is:
(component $App
(core module $Main
(type $i32-i32 (func (param i32) (result i32)))
(elem declare funcref (ref.func $inc)) ;; <- this line was added
(func $hof (param $f (ref $i32-i32)) (result i32)
(i32.add (i32.const 10) (call_ref $i32-i32 (i32.const 42) (local.get $f)))
)
(func $inc (param $i i32) (result i32)
(i32.add (local.get $i) (i32.const 1))
)
(func $caller (result i32)
(call $hof (ref.func $inc))
)
)
)
Test Case
Steps to Reproduce
$caller
function, everything works fine.Expected Results
No error reported
Actual Results
Versions and Environment
Wasmtime version or commit: git nightly
branch=main
,tag=a77e877
,features = ["component-model", "async", "gc"]
Operating system: Windows 11
See details on CI: https://github.com/valkyrie-language/valkyrie-runtime/actions/runs/9159552776/job/25180193563#step:6:188