From fe429302391000bb4749f86fda2f6dc09a7e22bc Mon Sep 17 00:00:00 2001 From: Lauri Virtanen Date: Mon, 16 Dec 2024 23:48:58 +0200 Subject: [PATCH] Take `log` function argument count from function context --- core/vdbe/mod.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/core/vdbe/mod.rs b/core/vdbe/mod.rs index 154d6f7e6..069782c9a 100644 --- a/core/vdbe/mod.rs +++ b/core/vdbe/mod.rs @@ -2520,15 +2520,21 @@ impl Program { MathFuncArity::UnaryOrBinary => match math_func { MathFunc::Log => { - let lhs = &state.registers[*start_reg]; - let rhs = state.registers.get(*start_reg + 1); - - let result = if let Some(arg) = rhs { - exec_math_log(arg, Some(lhs)) - } else { - exec_math_log(lhs, None) + let result = match arg_count { + 1 => { + let arg = &state.registers[*start_reg]; + exec_math_log(arg, None) + } + 2 => { + let base = &state.registers[*start_reg]; + let arg = &state.registers[*start_reg + 1]; + exec_math_log(arg, Some(base)) + } + _ => unreachable!( + "{:?} function with unexpected number of arguments", + math_func + ), }; - state.registers[*dest] = result; } _ => unreachable!(