]> granicus.if.org Git - vim/commitdiff
patch 8.2.2013: Vim9: not skipping white space after unary minus v8.2.2013
authorBram Moolenaar <Bram@vim.org>
Wed, 18 Nov 2020 16:39:05 +0000 (17:39 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 18 Nov 2020 16:39:05 +0000 (17:39 +0100)
Problem:    Vim9: not skipping white space after unary minus.
Solution:   Skip whitespace. (closes #7324)

src/testdir/test_vim9_expr.vim
src/version.c
src/vim9compile.c

index b7897fe7cb4201bc5b6606dbb997c56e5232e277..156d24462991af9d896d30f21b7f5665d17a8744 100644 (file)
@@ -2300,12 +2300,29 @@ def Test_expr7_parens_vim9script()
   CheckScriptSuccess(lines)
 enddef
 
-def Test_expr7_negate()
+def Test_expr7_negate_add()
   assert_equal(-99, -99)
+  assert_equal(-99, - 99)
   assert_equal(99, --99)
+  assert_equal(99, -- 99)
+  assert_equal(99, - - 99)
+  assert_equal(99, +99)
+  assert_equal(-99, -+99)
+  assert_equal(-99, -+ 99)
+  assert_equal(-99, - +99)
+  assert_equal(-99, - + 99)
+  assert_equal(-99, +-99)
+  assert_equal(-99, + -99)
+  assert_equal(-99, + - 99)
+
   var nr = 88
   assert_equal(-88, -nr)
-  assert_equal(88, --nr)
+  assert_equal(-88, - nr)
+  assert_equal(-88, - +nr)
+  assert_equal(88, -- nr)
+  assert_equal(88, + nr)
+  assert_equal(88, --+ nr)
+  assert_equal(88, - - nr)
 enddef
 
 def Echo(arg: any): string
index 0f0ccda25adc7397e4a0bec3be6fe52ba87a6e8f..3f5cd797cfcb54bb2345f981740a64b2c9793736 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2013,
 /**/
     2012,
 /**/
index c5d92aa1b847c86a1892eaf5085ec60c81f7f064..2c522809d992b37acf66ac4d99805d7777e9c690 100644 (file)
@@ -3362,6 +3362,8 @@ compile_leader(cctx_T *cctx, int numeric_only, char_u *start, char_u **end)
     while (p > start)
     {
        --p;
+       while (VIM_ISWHITE(*p))
+           --p;
        if (*p == '-' || *p == '+')
        {
            int     negate = *p == '-';