]> granicus.if.org Git - vim/commitdiff
patch 8.2.4311: Vim9: changing script variable type not caught compile time v8.2.4311
authorBram Moolenaar <Bram@vim.org>
Sun, 6 Feb 2022 17:17:02 +0000 (17:17 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 6 Feb 2022 17:17:02 +0000 (17:17 +0000)
Problem:    Vim9: changing script variable type not caught at compile time.
Solution:   Set the declared type.

src/testdir/test_vim9_assign.vim
src/version.c
src/vim9instr.c

index 79c08d3f443250c749b3b05d8307cc6a08664454..7d3e2c13562af29457c930783376422ffde0b139 100644 (file)
@@ -692,6 +692,16 @@ def Test_extend_list()
   END
   v9.CheckDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>', 4)
   unlet g:myList
+
+  lines =<< trim END
+      vim9script
+      var lds = [1, 2, 3]
+      def Func()
+          echo lds->extend(['x'])
+      enddef
+      defcompile
+  END
+  v9.CheckScriptFailure(lines, 'E1013:')
 enddef
 
 def Test_extend_dict()
index 20bc28ab46818b660d1074e9657152948b64eb5b..2342462a0fb535ceaa589270c8873bdcaf100d3a 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4311,
 /**/
     4310,
 /**/
index cf26650d17b914770fd90691aaf2de00c0ac2d1e..9116f4111c6341481d958920ade121f4e18f2ce5 100644 (file)
@@ -1040,7 +1040,7 @@ generate_VIM9SCRIPT(
 
     RETURN_OK_IF_SKIP(cctx);
     if (isn_type == ISN_LOADSCRIPT)
-       isn = generate_instr_type(cctx, isn_type, type);
+       isn = generate_instr_type2(cctx, isn_type, type, type);
     else
        isn = generate_instr_drop(cctx, isn_type, 1);
     if (isn == NULL)