Mercurial > vim
diff src/evalfunc.c @ 17534:2b4c138bf8e9 v8.1.1765
patch 8.1.1765: get(func, dict, def) does not work properly
commit https://github.com/vim/vim/commit/f91aac5e3e3b8b1633d84eac2687ebbd76d8133b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 28 13:21:01 2019 +0200
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 https://github.com/vim/vim/issues/4734)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 28 Jul 2019 13:30:07 +0200 |
parents | ef23ec1eee54 |
children | 554240b9574b |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -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