Mercurial > vim
diff src/evalvars.c @ 22802:3e0f909ca1f2 v8.2.1949
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Commit: https://github.com/vim/vim/commit/348be7ed07d164970ec0004bc278e254eb0cf5bf
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Nov 4 11:36:35 2020 +0100
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Problem: Vim9: using extend() on null dict is silently ignored.
Solution: Give an error message. Initialize a dict variable with an empty
dictionary. (closes #7251)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 04 Nov 2020 11:45:06 +0100 |
parents | ba3f547dc490 |
children | 4759d13193fb |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -2553,7 +2553,22 @@ eval_variable( ret = FAIL; } else if (rettv != NULL) + { + // If a list or dict variable wasn't initialized, do it now. + if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL) + { + tv->vval.v_dict = dict_alloc(); + if (tv->vval.v_dict != NULL) + ++tv->vval.v_dict->dv_refcount; + } + else if (tv->v_type == VAR_LIST && tv->vval.v_list == NULL) + { + tv->vval.v_list = list_alloc(); + if (tv->vval.v_list != NULL) + ++tv->vval.v_list->lv_refcount; + } copy_tv(tv, rettv); + } } name[len] = cc;