diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-27 16:29:53 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-27 16:29:53 +0100 |
commit | ec15b1cfdc5faadb529dedda58adf7fc98c839ed (patch) | |
tree | cdcf7ffa3e2ed7de3fc890f6415a0be84ad1e490 /src/evalvars.c | |
parent | c75bca3ee955ff36ece99a42041733ddea5f45a7 (diff) |
patch 8.2.4634: Vim9: cannot initialize a variable to null_listv8.2.4634
Problem: Vim9: cannot initialize a variable to null_list.
Solution: Give negative count to NEWLIST. (closes #10027)
Also fix inconsistencies in comparing with null values.
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index 058e8048f6..19a0f33894 100644 --- 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); } |