diff src/evalvars.c @ 28231:66b245d84f37 v8.2.4642

patch 8.2.4642: Vim9: in :def function script var cannot be null Commit: https://github.com/vim/vim/commit/859cc21c6b60af07b549456b7d050a03b3e48bc9 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 28 15:22:35 2022 +0100 patch 8.2.4642: Vim9: in :def function script var cannot be null 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)
author Bram Moolenaar <Bram@vim.org>
date Mon, 28 Mar 2022 16:30:03 +0200
parents 300b0ca4e46c
children fff70771d4bb
line wrap: on
line diff
--- 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);
 	}