From f8ba01a6881371c1751e2e007b3d31d718b44360 Mon Sep 17 00:00:00 2001 From: Micha de Vries Date: Mon, 12 Aug 2024 11:05:12 +0200 Subject: [PATCH] Fix "specific" match statement exiting early (#4492) --- core/src/fnc/mod.rs | 2 +- lib/tests/function.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/fnc/mod.rs b/core/src/fnc/mod.rs index ddc59edd..f89ed27a 100644 --- a/core/src/fnc/mod.rs +++ b/core/src/fnc/mod.rs @@ -74,7 +74,7 @@ macro_rules! dispatch { $($wrapper)*(|| $($function_path)::+($($ctx_arg,)* args))()$(.$await)* },)+ _ => { - return Err($crate::err::Error::InvalidFunction{ + Err($crate::err::Error::InvalidFunction{ name: String::from($name), message: $message.to_string() }) diff --git a/lib/tests/function.rs b/lib/tests/function.rs index 95c65752..aaf5fa45 100644 --- a/lib/tests/function.rs +++ b/lib/tests/function.rs @@ -6237,6 +6237,9 @@ async fn function_idiom_chaining() -> Result<(), Error> { true.is_bool(); true.doesnt_exist(); field.bla.nested.is_none(); + // String is one of the types in the initial match statement, + // this test ensures that the dispatch macro does not exit early + "string".is_bool(); "#; Test::new(sql) .await? @@ -6245,6 +6248,7 @@ async fn function_idiom_chaining() -> Result<(), Error> { .expect_val("false")? .expect_val("true")? .expect_error("There was a problem running the doesnt_exist() function. no such method found for the bool type")? - .expect_val("true")?; + .expect_val("true")? + .expect_val("false")?; Ok(()) }