]> granicus.if.org Git - vim/commitdiff
patch 8.2.4395: some code lines not covered by tests v8.2.4395
authorBram Moolenaar <Bram@vim.org>
Tue, 15 Feb 2022 21:17:56 +0000 (21:17 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 15 Feb 2022 21:17:56 +0000 (21:17 +0000)
Problem:    Some code lines not covered by tests.
Solution:   Add a few more test cases.  Fix getting more than one error for
            invalid assignment.

src/errors.h
src/evalvars.c
src/testdir/test_vim9_assign.vim
src/testdir/test_vim9_cmd.vim
src/testdir/test_vim9_func.vim
src/version.c
src/vim9compile.c

index d6b82bbfb00a0bee16a9439b510ecf9eef7f7836..8e2b9da6c6f88eca8cbb59a7d384edd76276c281 100644 (file)
@@ -2788,7 +2788,8 @@ EXTERN char e_missing_argument_type_for_str[]
        INIT(= N_("E1077: Missing argument type for %s"));
 // E1078 unused
 // E1079 unused
-// E1080 unused
+EXTERN char e_invalid_assignment[]
+       INIT(= N_("E1080: Invalid assignment"));
 EXTERN char e_cannot_unlet_str[]
        INIT(= N_("E1081: Cannot unlet %s"));
 #endif
index 8e862df8bb8166721f17808832acc1044e196435..40375588c28434e36c07c1ab08671e2be882b1e7 100644 (file)
@@ -1107,7 +1107,8 @@ skip_var_list(
            {
                if (*semicolon == 1)
                {
-                   emsg(_(e_double_semicolon_in_list_of_variables));
+                   if (!silent)
+                       emsg(_(e_double_semicolon_in_list_of_variables));
                    return NULL;
                }
                *semicolon = 1;
index 9c988c96ffab9747bb992b630ea8f3b3065e1577..c4a457e81b796daf45f0e6f15f0037aaea0ee309 100644 (file)
@@ -1359,7 +1359,8 @@ def Test_assignment_failure()
   v9.CheckDefFailure(['var null = 1'], 'E1034:')
   v9.CheckDefFailure(['var this = 1'], 'E1034:')
 
-  v9.CheckDefFailure(['[a; b; c] = g:list'], 'E452:')
+  v9.CheckDefFailure(['[a; b; c] = g:list'], 'E1001:')
+  v9.CheckDefFailure(['var [a; b; c] = g:list'], 'E1080:')
   v9.CheckDefExecFailure(['var a: number',
                        '[a] = test_null_list()'], 'E1093:')
   v9.CheckDefExecFailure(['var a: number',
index f80d5a26d16cd99a488194e7fe6eddb3534f91cf..10be6910afbfda3a5c784a20524ffde3915452ec 100644 (file)
@@ -1354,6 +1354,13 @@ def Test_command_not_recognized()
   END
   v9.CheckDefFailure(lines, 'E1146:', 1)
 
+  lines =<< trim END
+    if 0
+      d.key = 'asdf'
+    endif
+  END
+  v9.CheckDefSuccess(lines)
+
   lines =<< trim END
     d['key'] = 'asdf'
   END
@@ -1621,6 +1628,11 @@ def Test_substitute_expr()
   s/text/\=['aaa', 'bbb', 'ccc']/
   assert_equal(['some aaa', 'bbb', 'ccc', ' here'], getline(1, '$'))
   bwipe!
+
+  # inside "if 0" substitute is ignored
+  if 0
+    s/a/\=nothing/ and | some more
+  endif
 enddef
 
 def Test_redir_to_var()
@@ -1663,6 +1675,12 @@ def Test_redir_to_var()
   END
   v9.CheckDefFailure(lines, 'E1089:')
 
+  lines =<< trim END
+    var text: string
+    redir => text
+  END
+  v9.CheckDefFailure(lines, 'E1185:')
+
   lines =<< trim END
     var ls = 'asdf'
     redir => ls[1]
index ecc9c64df5254003845da10a6832b560b9e715bb..65d6dc8f91d960c03b27b678f7dcbccd893ea662 100644 (file)
@@ -3762,7 +3762,15 @@ def Test_go_beyond_end_of_cmd()
   v9.CheckScriptFailure(lines, 'E476:')
 enddef
 
+" The following messes up syntax highlight, keep near the end.
 if has('python3')
+  def Test_python3_command()
+    py3 import vim
+    py3 vim.command("let g:done = 'yes'")
+    assert_equal('yes', g:done)
+    unlet g:done
+  enddef
+
   def Test_python3_heredoc()
     py3 << trim EOF
       import vim
@@ -3778,7 +3786,6 @@ if has('python3')
   enddef
 endif
 
-" This messes up syntax highlight, keep near the end.
 if has('lua')
   def Test_lua_heredoc()
     g:d = {}
index 3510af8a8f014fe6b86d6bd7248150c03208ff6a..e07308627b666b320d5f72b161ae480d343133bb 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4395,
 /**/
     4394,
 /**/
index 0eb41e4c132b6f73b932e1394e34f44b10f8178c..74dc5e0b03f624338f0f7ab838dfa7145a9b4d5f 100644 (file)
@@ -2420,7 +2420,7 @@ may_compile_assignment(exarg_T *eap, char_u **line, cctx_T *cctx)
 
     if (*eap->cmd == '[')
     {
-       // [var, var] = expr
+       // might be "[var, var] = expr"
        *line = compile_assignment(eap->cmd, eap, CMD_SIZE, cctx);
        if (*line == NULL)
            return FAIL;
@@ -2958,7 +2958,10 @@ compile_def_function(
            case CMD_decrement:
                    line = compile_assignment(p, &ea, ea.cmdidx, &cctx);
                    if (line == p)
+                   {
+                       emsg(_(e_invalid_assignment));
                        line = NULL;
+                   }
                    break;
 
            case CMD_unlet: