changeset 20915:a3853794a768 v8.2.1009

patch 8.2.1009: Vim9: some failures not checked for Commit: https://github.com/vim/vim/commit/c5b1c20b6b1968873ea31edac1db659773b3b93d Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 18 22:43:27 2020 +0200 patch 8.2.1009: Vim9: some failures not checked for Problem: Vim9: some failures not checked for. Solution: Add test cases. Remove unused code.
author Bram Moolenaar <Bram@vim.org>
date Thu, 18 Jun 2020 22:45:03 +0200
parents f62d75f4ba60
children 3fb9b2b0a0ba
files src/testdir/test_vim9_script.vim src/version.c src/vim9execute.c
diffstat 3 files changed, 24 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -127,6 +127,7 @@ def Test_assignment_list()
   list2[-3] = 77
   assert_equal([77, 88, 99], list2)
   call CheckDefExecFailure(['let ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:')
+  call CheckDefExecFailure(['let [v1, v2] = [1, 2]'], 'E1092:')
 
   # type becomes list<any>
   let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c']
@@ -1920,6 +1921,20 @@ def Test_let_declaration()
   unlet g:other_var
 enddef
 
+def Test_let_declaration_fails()
+  let lines =<< trim END
+    vim9script
+    const var: string
+  END
+  CheckScriptFailure(lines, 'E1021:')
+
+  lines =<< trim END
+    vim9script
+    let 9var: string
+  END
+  CheckScriptFailure(lines, 'E475:')
+enddef
+
 def Test_let_type_check()
   let lines =<< trim END
     vim9script
@@ -1933,6 +1948,12 @@ def Test_let_type_check()
     let var:string
   END
   CheckScriptFailure(lines, 'E1069:')
+
+  lines =<< trim END
+    vim9script
+    let var: asdf
+  END
+  CheckScriptFailure(lines, 'E1010:')
 enddef
 
 def Test_forward_declaration()
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1009,
+/**/
     1008,
 /**/
     1007,
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -2119,12 +2119,8 @@ call_def_function(
 		    list_T	*list;
 		    int		count = iptr->isn_arg.number;
 
+		    // type will have been checked to be a list
 		    tv = STACK_TV_BOT(-1);
-		    if (tv->v_type != VAR_LIST)
-		    {
-			emsg(_(e_listreq));
-			goto failed;
-		    }
 		    list = tv->vval.v_list;
 
 		    // no error for short list, expect it to be checked earlier