From 73ceed0f6029f983248ff264997db1b5f9f29c1a Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Fri, 13 Oct 2023 23:53:15 -0400 Subject: [PATCH] #354 another reversion --- scada-common/util.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scada-common/util.lua b/scada-common/util.lua index 76b7ff6..11dc2a8 100644 --- a/scada-common/util.lua +++ b/scada-common/util.lua @@ -66,9 +66,10 @@ function util.println_ts(message) print(os.date(p_time) .. tostring(message)) en ---@param val any ---@return string function util.strval(val) - if type(val) == "string" then return val end + local t = type(val) + if t == "string" then return val end -- this depends on Lua short-circuiting the or check for metatables (note: metatables won't have metatables) - if (type(val) == "table" and (getmetatable(val) == nil or getmetatable(val).__tostring == nil)) or type(val) == "function" then + if (t == "table" and (getmetatable(val) == nil or getmetatable(val).__tostring == nil)) or t == "function" then return table.concat{"[", tostring(val), "]"} else return tostring(val) end end