From 4a63a4d86e9cbfc9987fb6910aef71087087911d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 21 Apr 2020 12:43:05 -0500 Subject: [PATCH] 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. --- crates/api/src/func.rs | 2 +- tests/all/func.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/api/src/func.rs b/crates/api/src/func.rs index b6a4dec62f..ade4917b99 100644 --- a/crates/api/src/func.rs +++ b/crates/api/src/func.rs @@ -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. diff --git a/tests/all/func.rs b/tests/all/func.rs index 1cbb3e0814..40616810ed 100644 --- a/tests/all/func.rs +++ b/tests/all/func.rs @@ -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(), &[]);