]> granicus.if.org Git - vim/commitdiff
patch 8.2.3048: strange error for white space after ++ command v8.2.3048
authorBram Moolenaar <Bram@vim.org>
Fri, 25 Jun 2021 19:31:09 +0000 (21:31 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 25 Jun 2021 19:31:09 +0000 (21:31 +0200)
Problem:    Strange error for white space after ++ command.
Solution:   Check for white space explicitly. (closes #8440)

src/errors.h
src/testdir/test_vim9_assign.vim
src/version.c
src/vim9compile.c
src/vim9script.c

index 8a2461b31eb8cb9f681e69ff43f69e2da48d3a78..b4cf8ae54ba6189057094dd391321486f1f21a62 100644 (file)
@@ -446,3 +446,5 @@ EXTERN char e_libsodium_decryption_failed[]
        INIT(= N_("E1200: Decryption failed!"));
 EXTERN char e_libsodium_decryption_failed_premature[]
        INIT(= N_("E1201: Decryption failed: pre-mature end of file!"));
+EXTERN char e_no_white_space_allowed_after_str_str[]
+       INIT(= N_("E1202: No white space allowed after '%s': %s"));
index a26867f597d491261f33bfc48b5288f58d6e7303..cba79729c18c6b2d463e333e23c3103aa0e986da 100644 (file)
@@ -1906,6 +1906,12 @@ def Test_inc_dec()
       unlet g:count
   END
   CheckDefAndScriptSuccess(lines)
+
+  lines =<< trim END
+      var nr = 7
+      ++ nr
+  END
+  CheckDefAndScriptFailure(lines, "E1202: No white space allowed after '++': ++ nr")
 enddef
 
 
index 3898725e782d43594a43034e48231a0bd19d0421..4cef712b66ed27b1ddc6cfd0df2550114c714a74 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3048,
 /**/
     3047,
 /**/
index e78a032cb59f7fd1fa4fb3d5b85a7698945701fc..cd83aea7362ba342dff1c76e7ca264c32856e4ba 100644 (file)
@@ -6639,6 +6639,12 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
     }
     if (eap->cmdidx == CMD_increment || eap->cmdidx == CMD_decrement)
     {
+       if (VIM_ISWHITE(eap->cmd[2]))
+       {
+           semsg(_(e_no_white_space_allowed_after_str_str),
+                        eap->cmdidx == CMD_increment ? "++" : "--", eap->cmd);
+           return NULL;
+       }
        op = (char_u *)(eap->cmdidx == CMD_increment ? "+=" : "-=");
        oplen = 2;
        incdec = TRUE;
index 7c6526b659af053721301e5d68b41c34c57f4504..9dc67a789dab15f0b0c3c707c448474a6e97b155 100644 (file)
@@ -169,6 +169,13 @@ ex_incdec(exarg_T *eap)
     char_u     *nextcmd = eap->nextcmd;
     size_t     len = STRLEN(eap->cmd) + 8;
 
+    if (VIM_ISWHITE(cmd[2]))
+    {
+       semsg(_(e_no_white_space_allowed_after_str_str),
+                        eap->cmdidx == CMD_increment ? "++" : "--", eap->cmd);
+       return;
+    }
+
     // This works like "nr += 1" or "nr -= 1".
     // Add a '|' to avoid looking in the next line.
     eap->cmd = alloc(len);