From 48e0380dbebcd221571121524d0a781c0870036a Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sat, 27 Aug 2022 01:02:29 +0100 Subject: [PATCH] Ensure math::sum() returns a number when being called on a non-array value Closes #65 --- lib/src/fnc/math.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/fnc/math.rs b/lib/src/fnc/math.rs index 99ffd02e..5e444205 100644 --- a/lib/src/fnc/math.rs +++ b/lib/src/fnc/math.rs @@ -150,7 +150,7 @@ pub fn stddev(_: &Context, mut args: Vec) -> Result { pub fn sum(_: &Context, mut args: Vec) -> Result { match args.remove(0) { Value::Array(v) => Ok(v.as_numbers().into_iter().sum::().into()), - _ => Ok(Value::None), + v => Ok(v.as_number().into()), } }