vim-patch:8.2.0619: null dict is not handled like an empty dict

Problem:    Null dict is not handled like an empty dict.
Solution:   Fix the code and add tests. (Yegappan Lakshmanan, closes vim/vim#5968)

ea04a6e8ba

Nvim doesn't support modifying NULL list, so comment out a line.
This commit is contained in:
zeertzjq
2022-10-26 19:53:54 +08:00
parent cfccae9584
commit ef363ed37c
10 changed files with 72 additions and 24 deletions

View File

@@ -2490,10 +2490,14 @@ bool tv_dict_equal(dict_T *const d1, dict_T *const d2, const bool ic, const bool
if (d1 == d2) {
return true;
}
if (d1 == NULL || d2 == NULL) {
if (tv_dict_len(d1) != tv_dict_len(d2)) {
return false;
}
if (tv_dict_len(d1) != tv_dict_len(d2)) {
if (tv_dict_len(d1) == 0) {
// empty and NULL dicts are considered equal
return true;
}
if (d1 == NULL || d2 == NULL) {
return false;
}