From 7fca3ddccad2130e75c68e94b5bf4db925b1911b Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Thu, 22 Oct 2020 14:32:19 -0400 Subject: [PATCH] fixup: some small nit picks --- src/nvim/api/private/helpers.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index dbc4e16d09..41b0f8ae1d 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -1621,14 +1621,18 @@ free_exit: /// Force obj to bool. /// If it fails, returns false and sets err -bool api_coerce_to_bool(Object obj, const char *what, bool nil_truthy, Error *err) +/// @param obj The object to coerce to a boolean +/// @param what The name of the object, used for error message +/// @param if_nil What to return if the type is nil. +/// @param err Set if there was an error in converting to a bool +bool api_coerce_to_bool(Object obj, const char *what, bool if_nil, Error *err) { if (obj.type == kObjectTypeBoolean) { return obj.data.boolean; } else if (obj.type == kObjectTypeInteger) { return obj.data.integer; // C semantics: non-zero int is true } else if (obj.type == kObjectTypeNil) { - return nil_truthy; // caller decides what NIL (missing retval in lua) means + return if_nil; // caller decides what NIL (missing retval in lua) means } else { api_set_error(err, kErrorTypeValidation, "%s is not an boolean", what); return false;