Patch 8.2.1851
Problem:    Vim9: "!" followed by space incorrectly used.
Solution:   Skip over trailing spaces. (closes #7131)
Files:      src/eval.c, src/vim9compile.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1850/src/eval.c  2020-10-11 21:34:37.115264199 +0200
--- src/eval.c  2020-10-15 21:37:05.201265815 +0200
***************
*** 3390,3399 ****
--- 3390,3403 ----
        f = rettv->vval.v_float;
      else
  #endif
+     {
+       while (VIM_ISWHITE(end_leader[-1]))
+           --end_leader;
        if (in_vim9script() && end_leader[-1] == '!')
            val = tv2bool(rettv);
        else
            val = tv_get_number_chk(rettv, &error);
+     }
      if (error)
      {
        clear_tv(rettv);
*** ../vim-8.2.1850/src/vim9compile.c   2020-10-15 13:57:52.098225999 +0200
--- src/vim9compile.c   2020-10-15 21:52:53.600992517 +0200
***************
*** 3041,3047 ****
            ++p;
            break;
        }
!       else
        {
            int v = tv2bool(rettv);
  
--- 3041,3047 ----
            ++p;
            break;
        }
!       else if (*p == '!')
        {
            int v = tv2bool(rettv);
  
***************
*** 3178,3189 ****
        }
        else
        {
!           int  invert = TRUE;
  
!           while (p > start && p[-1] == '!')
            {
                --p;
-               invert = !invert;
            }
            if (generate_2BOOL(cctx, invert) == FAIL)
                return FAIL;
--- 3178,3190 ----
        }
        else
        {
!           int  invert = *p == '!';
  
!           while (p > start && (p[-1] == '!' || VIM_ISWHITE(p[-1])))
            {
+               if (p[-1] == '!')
+                   invert = !invert;
                --p;
            }
            if (generate_2BOOL(cctx, invert) == FAIL)
                return FAIL;
*** ../vim-8.2.1850/src/testdir/test_vim9_expr.vim      2020-10-11 
21:34:37.115264199 +0200
--- src/testdir/test_vim9_expr.vim      2020-10-15 21:50:38.245498437 +0200
***************
*** 2292,2297 ****
--- 2292,2313 ----
        assert_equal(true, !!'asdf')
        assert_equal(true, !![2])
  
+       assert_equal(true, ! false)
+       assert_equal(true, !! true)
+       assert_equal(true, ! ! true)
+       assert_equal(true, !!! false)
+       assert_equal(true, ! ! ! false)
+ 
+       g:true = true
+       g:false = false
+       assert_equal(true, ! g:false)
+       assert_equal(true, !! g:true)
+       assert_equal(true, ! ! g:true)
+       assert_equal(true, !!! g:false)
+       assert_equal(true, ! ! ! g:false)
+       unlet g:true
+       unlet g:false
+ 
        assert_equal(true, !test_null_partial())
        assert_equal(false, !{-> 'yes'})
  
***************
*** 2314,2321 ****
        assert_equal(false, ![1, 2, 3]->reverse())
        assert_equal(true, ![]->reverse())
    END
!   CheckDefSuccess(lines)
!   CheckScriptSuccess(['vim9script'] + lines)
  enddef
  
  func Test_expr7_fails()
--- 2330,2336 ----
        assert_equal(false, ![1, 2, 3]->reverse())
        assert_equal(true, ![]->reverse())
    END
!   CheckDefAndScriptSuccess(lines)
  enddef
  
  func Test_expr7_fails()
*** ../vim-8.2.1850/src/version.c       2020-10-15 21:23:25.163883137 +0200
--- src/version.c       2020-10-15 21:53:52.028779187 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1851,
  /**/

-- 
You are only young once, but you can stay immature indefinitely.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202010151955.09FJtQaV162237%40masaka.moolenaar.net.

Raspunde prin e-mail lui