diff src/vim9execute.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 69a48bcd1d80
children 0b12dd90a5d6
line wrap: on
line diff
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -4412,7 +4412,8 @@ exec_instructions(ectx_T *ectx)
 								       == NULL)
 		    {
 			SOURCING_LNUM = iptr->isn_lnum;
-			semsg(_(e_key_not_present_in_dictionary), iptr->isn_arg.string);
+			semsg(_(e_key_not_present_in_dictionary),
+							 iptr->isn_arg.string);
 			goto on_error;
 		    }
 		    // Put the dict used on the dict stack, it might be used by
@@ -4531,21 +4532,7 @@ exec_instructions(ectx_T *ectx)
 		break;
 
 	    case ISN_SETTYPE:
-		{
-		    checktype_T *ct = &iptr->isn_arg.type;
-
-		    tv = STACK_TV_BOT(-1);
-		    if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
-		    {
-			free_type(tv->vval.v_dict->dv_type);
-			tv->vval.v_dict->dv_type = alloc_type(ct->ct_type);
-		    }
-		    else if (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)
-		    {
-			free_type(tv->vval.v_list->lv_type);
-			tv->vval.v_list->lv_type = alloc_type(ct->ct_type);
-		    }
-		}
+		set_tv_type(STACK_TV_BOT(-1), iptr->isn_arg.type.ct_type);
 		break;
 
 	    case ISN_2BOOL: