Mercurial > vim
diff src/evalvars.c @ 28217:662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Commit: https://github.com/vim/vim/commit/ec15b1cfdc5faadb529dedda58adf7fc98c839ed
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 27 16:29:53 2022 +0100
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Problem: Vim9: cannot initialize a variable to null_list.
Solution: Give negative count to NEWLIST. (closes https://github.com/vim/vim/issues/10027)
Also fix inconsistencies in comparing with null values.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 27 Mar 2022 17:30:04 +0200 |
parents | b96409b84eaf |
children | 300b0ca4e46c |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -2816,11 +2816,13 @@ eval_variable( type = sv->sv_type; } - // If a list or dict variable wasn't initialized, do it now. - // Not for global variables, they are not declared. + // If a list or dict variable wasn't initialized and has meaningful + // type, do it now. Not for global variables, they are not + // declared. if (ht != &globvarht) { - if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL) + if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL + && type != NULL && type != &t_dict_empty) { tv->vval.v_dict = dict_alloc(); if (tv->vval.v_dict != NULL) @@ -2829,7 +2831,8 @@ eval_variable( tv->vval.v_dict->dv_type = alloc_type(type); } } - else if (tv->v_type == VAR_LIST && tv->vval.v_list == NULL) + else if (tv->v_type == VAR_LIST && tv->vval.v_list == NULL + && type != NULL && type != &t_list_empty) { tv->vval.v_list = list_alloc(); if (tv->vval.v_list != NULL) @@ -2838,12 +2841,6 @@ eval_variable( tv->vval.v_list->lv_type = alloc_type(type); } } - 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); }