diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-01 19:23:24 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-01 19:23:24 +0000 |
commit | 7a2222487507eb13cccdb9a66397092775d62b8c (patch) | |
tree | c5878917461a22b48ec7a38cb6356352b8e57895 /src/evalvars.c | |
parent | f01af9c4e6f1438cd1112cfff42f3837028c7846 (diff) |
patch 8.2.4487: Vim9: cannot compare with v:nullv8.2.4487
Problem: Vim9: cannot compare with v:null.
Solution: Allow comparing anything with v:null. (closes #9866)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index 96d60a9595..862d5192bb 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2816,30 +2816,34 @@ eval_variable( } // If a list or dict variable wasn't initialized, do it now. - if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL) + // Not for global variables, they are not declared. + if (ht != &globvarht) { - tv->vval.v_dict = dict_alloc(); - if (tv->vval.v_dict != NULL) + if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL) { - ++tv->vval.v_dict->dv_refcount; - tv->vval.v_dict->dv_type = alloc_type(type); + tv->vval.v_dict = dict_alloc(); + if (tv->vval.v_dict != NULL) + { + ++tv->vval.v_dict->dv_refcount; + tv->vval.v_dict->dv_type = alloc_type(type); + } } - } - else if (tv->v_type == VAR_LIST && tv->vval.v_list == NULL) - { - tv->vval.v_list = list_alloc(); - if (tv->vval.v_list != NULL) + 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; + tv->vval.v_list->lv_type = alloc_type(type); + } + } + else if (tv->v_type == VAR_BLOB && tv->vval.v_blob == NULL) { - ++tv->vval.v_list->lv_refcount; - tv->vval.v_list->lv_type = alloc_type(type); + tv->vval.v_blob = blob_alloc(); + if (tv->vval.v_blob != NULL) + ++tv->vval.v_blob->bv_refcount; } } - else if (tv->v_type == VAR_BLOB && tv->vval.v_blob == NULL) - { - tv->vval.v_blob = blob_alloc(); - if (tv->vval.v_blob != NULL) - ++tv->vval.v_blob->bv_refcount; - } copy_tv(tv, rettv); } } |