Fix return value of Func::param_arity (#1566)

Accidentally forgot to subtract 2 to account for the two vmctx
parameters, so let's add a test here nad adjust it appropriately.
This commit is contained in:
Alex Crichton
2020-04-21 12:43:05 -05:00
committed by GitHub
parent 7b24ff15db
commit 4a63a4d86e
2 changed files with 3 additions and 1 deletions

View File

@@ -502,7 +502,7 @@ impl Func {
.signatures()
.lookup(self.export.signature)
.expect("failed to lookup signature");
sig.params.len()
sig.params.len() - 2 // skip the two vmctx leading parameters
}
/// Returns the number of results this function produces.

View File

@@ -74,7 +74,9 @@ fn signatures_match() {
let f = Func::wrap(&store, || {});
assert_eq!(f.ty().params(), &[]);
assert_eq!(f.param_arity(), 0);
assert_eq!(f.ty().results(), &[]);
assert_eq!(f.result_arity(), 0);
let f = Func::wrap(&store, || -> i32 { loop {} });
assert_eq!(f.ty().params(), &[]);