From 21049241a4cdd38d668a487bdf8447ab63f85350 Mon Sep 17 00:00:00 2001 From: Benedikt Rips Date: Tue, 14 Feb 2023 12:28:13 +0100 Subject: [PATCH] fix: treat unset properties as nil Sometimes, the behaviour of function calls like `.setup(arg)` differs for `arg = nil` and `arg = {}`. To cover both cases, treat unset plugin spec properties as `nil`. For the latter case, one may set ` = {}` explicitly. --- lua/lazy/core/plugin.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index b79cc6b..9af0409 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -415,8 +415,8 @@ end ---@param prop string ---@param is_list? boolean function M.values(plugin, prop, is_list) - ---@type table - local ret = plugin._.super and M.values(plugin._.super, prop) or {} + ---@type table | nil + local ret = plugin._.super and M.values(plugin._.super, prop) local values = rawget(plugin, prop) if not values then @@ -427,7 +427,7 @@ function M.values(plugin, prop, is_list) end values = type(values) == "table" and values or { values } - return is_list and Util.extend(ret, values) or Util.merge(ret, values) + return is_list and Util.extend(ret or {}, values) or Util.merge(ret, values) end return M