fix(api): allow empty Lua table for nested dicts #22268

Problem:
The Lua-API bridge allows Dict params to be empty Lua (list) tables at
the function-signature level. But not for _nested_ Dicts, because they
are not modeled:
fae7540732/src/nvim/api/keysets.lua (L184)
Some API functions like nvim_cmd check for kObjectTypeDictionary and
don't handle the case of empty Lua tables (treated as "Array").

Solution:
Introduce VALIDATE_T_DICT and use it in places where
kObjectTypeDictionary was being checked directly.

fixes #21005
This commit is contained in:
Justin M. Keyes
2023-02-16 10:07:18 -05:00
committed by GitHub
parent bcae4af374
commit 09b3432eaf
5 changed files with 175 additions and 84 deletions

View File

@@ -1025,7 +1025,7 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e
// TODO(clason): handle via gen_api_dispatch
cterm_mask_provided = true;
} else if (HAS_KEY(dict->cterm)) {
VALIDATE_T("cterm", kObjectTypeDictionary, dict->cterm.type, {
VALIDATE_EXP(false, "cterm", "Dict", api_typename(dict->cterm.type), {
return hlattrs;
});
}