diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-28 15:22:35 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-28 15:22:35 +0100 |
commit | 859cc21c6b60af07b549456b7d050a03b3e48bc9 (patch) | |
tree | f2b27da6d782dc353fa52f8055b900b78997c6c7 /src/evalvars.c | |
parent | 471b3aed3e9c43d4dd53444ceb74f9a4f8a3874a (diff) |
patch 8.2.4642: Vim9: in :def function script var cannot be nullv8.2.4642
Problem: Vim9: in :def function script var cannot be null.
Solution: Only initialize a script variable when not set to a null value.
(closes #10034)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index b49178f125..202ada1914 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2823,7 +2823,7 @@ eval_variable( { if (tv->v_type == VAR_DICT && tv->vval.v_dict == NULL && ((type != NULL && type != &t_dict_empty) - || !in_vim9script())) + || !in_vim9script())) { tv->vval.v_dict = dict_alloc(); if (tv->vval.v_dict != NULL) @@ -2843,6 +2843,14 @@ eval_variable( tv->vval.v_list->lv_type = alloc_type(type); } } + else if (tv->v_type == VAR_BLOB && tv->vval.v_blob == NULL + && ((type != NULL && type != &t_blob_null) + || !in_vim9script())) + { + tv->vval.v_blob = blob_alloc(); + if (tv->vval.v_blob != NULL) + ++tv->vval.v_blob->bv_refcount; + } } copy_tv(tv, rettv); } |