]> granicus.if.org Git - vim/commitdiff
patch 8.2.1421: Vim9: handling "+" and "-" before number differs from script v8.2.1421
authorBram Moolenaar <Bram@vim.org>
Tue, 11 Aug 2020 18:51:08 +0000 (20:51 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 11 Aug 2020 18:51:08 +0000 (20:51 +0200)
Problem:    Vim9: handling "+" and "-" before number differs from Vim script.
Solution:   Use the same sequence of commands.

src/version.c
src/vim9compile.c

index a31436bd0fb576edbda9fab6af8ecc69654a1ad5..7411bc0d89e2f1ba5281243c775dcdb1430f150e 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1421,
 /**/
     1420,
 /**/
index d327b485556079834c1c8e402535c824288f8651..72c26ce46ee40966bca73bb19a86f9a53cc94f0c 100644 (file)
@@ -3206,6 +3206,15 @@ compile_expr7(
        case '9':
        case '.':   if (eval_number(arg, rettv, TRUE, FALSE) == FAIL)
                        return FAIL;
+                   // Apply "-" and "+" just before the number now, right to
+                   // left.  Matters especially when "->" follows.  Stops at
+                   // '!'.
+                   if (apply_leader(rettv, TRUE,
+                                           start_leader, &end_leader) == FAIL)
+                   {
+                       clear_tv(rettv);
+                       return FAIL;
+                   }
                    break;
 
        /*
@@ -3344,13 +3353,6 @@ compile_expr7(
 
     if (rettv->v_type != VAR_UNKNOWN && used_before == ppconst->pp_used)
     {
-       // apply the '-' and '+' before the constant, but not '!'
-       if (apply_leader(rettv, TRUE, start_leader, &end_leader) == FAIL)
-       {
-           clear_tv(rettv);
-           return FAIL;
-       }
-
        if (cctx->ctx_skip == SKIP_YES)
            clear_tv(rettv);
        else