diff src/evalvars.c @ 27517:f00a7a2bee21 v8.2.4286

patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy() Commit: https://github.com/vim/vim/commit/381692b6f1c2ec9b73a139500286ddc9347a1c01 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 2 20:01:27 2022 +0000 patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy() Problem: Vim9: strict type checking after copy() and deepcopy(). Solution: Allow type to change after making a copy. (closes https://github.com/vim/vim/issues/9644)
author Bram Moolenaar <Bram@vim.org>
date Wed, 02 Feb 2022 21:15:03 +0100
parents a14c4d3e3260
children d4921b91542c
line wrap: on
line diff
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -3695,24 +3695,7 @@ set_var_const(
     free_tv_arg = FALSE;
 
     if (vim9script && type != NULL)
-    {
-	if (type->tt_type == VAR_DICT && dest_tv->vval.v_dict != NULL)
-	{
-	    if (dest_tv->vval.v_dict->dv_type != type)
-	    {
-		free_type(dest_tv->vval.v_dict->dv_type);
-		dest_tv->vval.v_dict->dv_type = alloc_type(type);
-	    }
-	}
-	else if (type->tt_type == VAR_LIST && dest_tv->vval.v_list != NULL)
-	{
-	    if (dest_tv->vval.v_list->lv_type != type)
-	    {
-		free_type(dest_tv->vval.v_list->lv_type);
-		dest_tv->vval.v_list->lv_type = alloc_type(type);
-	    }
-	}
-    }
+	set_tv_type(dest_tv, type);
 
     // ":const var = value" locks the value
     // ":final var = value" locks "var"