mirror of
https://github.com/vim/vim.git
synced 2025-10-13 06:54:15 -04:00
patch 8.1.1765: get(func, dict, def) does not work properly
Problem: get(func, dict, def) does not work properly. Solution: Handle NULL dict better. (Takuya Fujiwara, closes #4734)
This commit is contained in:
@@ -4197,6 +4197,7 @@ f_get(typval_T *argvars, typval_T *rettv)
|
||||
dictitem_T *di;
|
||||
dict_T *d;
|
||||
typval_T *tv = NULL;
|
||||
int what_is_dict = FALSE;
|
||||
|
||||
if (argvars[0].v_type == VAR_BLOB)
|
||||
{
|
||||
@@ -4270,7 +4271,11 @@ f_get(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
}
|
||||
else if (STRCMP(what, "dict") == 0)
|
||||
rettv_dict_set(rettv, pt->pt_dict);
|
||||
{
|
||||
what_is_dict = TRUE;
|
||||
if (pt->pt_dict != NULL)
|
||||
rettv_dict_set(rettv, pt->pt_dict);
|
||||
}
|
||||
else if (STRCMP(what, "args") == 0)
|
||||
{
|
||||
rettv->v_type = VAR_LIST;
|
||||
@@ -4284,7 +4289,11 @@ f_get(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
else
|
||||
semsg(_(e_invarg2), what);
|
||||
return;
|
||||
|
||||
// When {what} == "dict" and pt->pt_dict == NULL, evaluate the
|
||||
// third argument
|
||||
if (!what_is_dict)
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user