From 13185a16ae4306fc13a45713381f0487c8e11526 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 23 Mar 2021 23:55:33 +0100 Subject: util.datamapper: Fix error on attempt to coerce nil to something Turns falsy values into nil instead of nothing, which ensures this function always has 1 return value, or table.insert({}) complains. Would still happen on some unexpected input, but that's actually a good thing. --- util/datamapper.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util') diff --git a/util/datamapper.lua b/util/datamapper.lua index 7aa916bc..68c09434 100644 --- a/util/datamapper.lua +++ b/util/datamapper.lua @@ -13,6 +13,9 @@ local function toboolean(s) end local function totype(t, s) + if not s then + return nil + end if t == "string" then return s elseif t == "boolean" then -- cgit v1.2.3