diff --git a/spec/src/run.rs b/spec/src/run.rs index e85f833..a74b526 100644 --- a/spec/src/run.rs +++ b/spec/src/run.rs @@ -13,8 +13,8 @@ use wasmi::{ GlobalInstance, GlobalRef, ImportResolver, ImportsBuilder, MemoryInstance, MemoryRef, ModuleImportResolver, ModuleInstance, ModuleRef, RuntimeValue, TableInstance, TableRef, ValueType, - load_from_buffer, LoadedModule, Signature, MemoryDescriptor, - TableDescriptor, GlobalDescriptor, FuncInstance, + load_from_buffer, LoadedModule, Signature, MemoryDescriptor, + TableDescriptor, GlobalDescriptor, FuncInstance, RuntimeArgs, }; #[derive(Debug)] @@ -57,7 +57,7 @@ impl Externals for SpecModule { fn invoke_index( &mut self, index: usize, - args: &[RuntimeValue], + args: RuntimeArgs, ) -> Result, InterpreterError> { match index { PRINT_FUNC_INDEX => { diff --git a/src/host.rs b/src/host.rs index 4557f40..13e722f 100644 --- a/src/host.rs +++ b/src/host.rs @@ -3,6 +3,7 @@ use value::{RuntimeValue, TryInto}; use Error; /// Safe wrapper for list of arguments +#[derive(Debug)] pub struct RuntimeArgs<'a>(&'a [RuntimeValue]); impl<'a> From<&'a [RuntimeValue]> for RuntimeArgs<'a> { @@ -94,4 +95,9 @@ mod tests { assert_eq!(val, 0); } + #[test] + fn i64_invalid_arg_cast() { + let args: RuntimeArgs = (&[RuntimeValue::I64(90534534545322)][..]).into(); + assert!(args.nth::(0).is_err()); + } } \ No newline at end of file diff --git a/src/tests/host.rs b/src/tests/host.rs index 96570f3..7795753 100644 --- a/src/tests/host.rs +++ b/src/tests/host.rs @@ -1,8 +1,7 @@ use { Error, Signature, Externals, FuncInstance, FuncRef, HostError, ImportsBuilder, MemoryInstance, MemoryRef, TableInstance, TableRef, ModuleImportResolver, ModuleInstance, ModuleRef, - RuntimeValue, TryInto, LoadedModule, load_from_buffer, TableDescriptor, MemoryDescriptor, - RuntimeArgs, + RuntimeValue, RuntimeArgs, LoadedModule, load_from_buffer, TableDescriptor, MemoryDescriptor, }; use types::ValueType; use wabt::wat2wasm;