From 0b96be7af2d763cb324c392fbd6cfca5f1f3397b Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sun, 5 Jun 2022 04:10:51 +0200 Subject: [PATCH] Make `common.merge` work with invalid arguments This is needed because users could try to enable plugins with `config.plugins.plugin_name = true`. Before, this would result in `common.merge` throwing an error; now it just returns a copy of the "base" table. --- data/core/common.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/data/core/common.lua b/data/core/common.lua index 1aa2b86e..6b4d9782 100644 --- a/data/core/common.lua +++ b/data/core/common.lua @@ -18,9 +18,16 @@ end function common.merge(a, b) + a = type(a) == "table" and a or {} local t = {} - for k, v in pairs(a) do t[k] = v end - if b then for k, v in pairs(b) do t[k] = v end end + for k, v in pairs(a) do + t[k] = v + end + if b and type(b) == "table" then + for k, v in pairs(b) do + t[k] = v + end + end return t end