diff --git a/RELEASES.md b/RELEASES.md index 902cd855..cb155381 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4,6 +4,12 @@ Rhai Release Notes Version 0.19.0 ============== +Bug fixes +--------- + +* `if` statement with an empty `true` block would not evaluate the `false` block. This is now fixed. +* Fixes a bug in `Module::set_fn_4_mut`. + New features ------------ diff --git a/src/module.rs b/src/module.rs index 3513dd7f..4d70b169 100644 --- a/src/module.rs +++ b/src/module.rs @@ -913,7 +913,7 @@ impl Module { TypeId::of::(), TypeId::of::(), TypeId::of::(), - TypeId::of::(), + TypeId::of::(), ]; self.set_fn(name, Public, &arg_types, Func::from_method(Box::new(f))) } diff --git a/tests/modules.rs b/tests/modules.rs index 06f5e37e..0744fd8c 100644 --- a/tests/modules.rs +++ b/tests/modules.rs @@ -78,6 +78,15 @@ fn test_module_resolver() -> Result<(), Box> { Ok(()) }); + #[cfg(not(feature = "no_float"))] + module.set_fn_4_mut( + "sum_of_three_args".to_string(), + |target: &mut INT, a: INT, b: INT, c: f64| { + *target = a + b + c as INT; + Ok(()) + } + ); + resolver.insert("hello", module); let mut engine = Engine::new(); @@ -130,6 +139,20 @@ fn test_module_resolver() -> Result<(), Box> { )?, 42 ); + #[cfg(not(feature = "no_float"))] + { + assert_eq!( + engine.eval::( + r#" + import "hello" as h; + let x = 21; + h::sum_of_three_args(x, 14, 26, 2.0); + x + "# + )?, + 42 + ); + } #[cfg(not(feature = "unchecked"))] {