Patch 8.2.2895
Problem:    Vim9: random characters appear in some error messages.
Solution:   Pass the correct pointer. (closes #8277)
Files:      src/eval.c, src/vim9compile.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.2894/src/eval.c  2021-05-28 13:50:13.821107364 +0200
--- src/eval.c  2021-05-28 17:36:25.238969410 +0200
***************
*** 2358,2364 ****
            ++*arg;
        if (evaluate && vim9script && !IS_WHITE_OR_NUL((*arg)[1]))
        {
!           error_white_both(p, op_falsy ? 2 : 1);
            clear_tv(rettv);
            return FAIL;
        }
--- 2358,2364 ----
            ++*arg;
        if (evaluate && vim9script && !IS_WHITE_OR_NUL((*arg)[1]))
        {
!           error_white_both(*arg - (op_falsy ? 1 : 0), op_falsy ? 2 : 1);
            clear_tv(rettv);
            return FAIL;
        }
***************
*** 2406,2412 ****
             */
            if (evaluate && vim9script && !IS_WHITE_OR_NUL((*arg)[1]))
            {
!               error_white_both(p, 1);
                clear_tv(rettv);
                evalarg_used->eval_flags = orig_flags;
                return FAIL;
--- 2406,2412 ----
             */
            if (evaluate && vim9script && !IS_WHITE_OR_NUL((*arg)[1]))
            {
!               error_white_both(*arg, 1);
                clear_tv(rettv);
                evalarg_used->eval_flags = orig_flags;
                return FAIL;
***************
*** 2511,2517 ****
             */
            if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))
            {
!               error_white_both(p, 2);
                clear_tv(rettv);
                return FAIL;
            }
--- 2511,2517 ----
             */
            if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))
            {
!               error_white_both(*arg, 2);
                clear_tv(rettv);
                return FAIL;
            }
***************
*** 2637,2643 ****
             */
            if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))
            {
!               error_white_both(p, 2);
                clear_tv(rettv);
                return FAIL;
            }
--- 2637,2643 ----
             */
            if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))
            {
!               error_white_both(*arg, 2);
                clear_tv(rettv);
                return FAIL;
            }
***************
*** 2735,2744 ****
                                   ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
  
        if (getnext)
            *arg = eval_next_line(evalarg);
        else if (evaluate && vim9script && !VIM_ISWHITE(**arg))
        {
!           error_white_both(p, len);
            clear_tv(rettv);
            return FAIL;
        }
--- 2735,2747 ----
                                   ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
  
        if (getnext)
+       {
            *arg = eval_next_line(evalarg);
+           p = *arg;
+       }
        else if (evaluate && vim9script && !VIM_ISWHITE(**arg))
        {
!           error_white_both(*arg, len);
            clear_tv(rettv);
            return FAIL;
        }
***************
*** 2898,2904 ****
        {
            if (evaluate && vim9script && !VIM_ISWHITE(**arg))
            {
!               error_white_both(p, oplen);
                clear_tv(rettv);
                return FAIL;
            }
--- 2901,2907 ----
        {
            if (evaluate && vim9script && !VIM_ISWHITE(**arg))
            {
!               error_white_both(*arg, oplen);
                clear_tv(rettv);
                return FAIL;
            }
***************
*** 3130,3136 ****
        {
            if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
            {
!               error_white_both(p, 1);
                clear_tv(rettv);
                return FAIL;
            }
--- 3133,3139 ----
        {
            if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
            {
!               error_white_both(*arg, 1);
                clear_tv(rettv);
                return FAIL;
            }
*** ../vim-8.2.2894/src/vim9compile.c   2021-05-22 21:40:35.385799988 +0200
--- src/vim9compile.c   2021-05-28 17:41:14.998107691 +0200
***************
*** 5187,5193 ****
        if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1 + op_falsy]))
        {
            semsg(_(e_white_space_required_before_and_after_str_at_str),
!                                                 op_falsy ? "??" : "?", *arg);
            return FAIL;
        }
  
--- 5187,5193 ----
        if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1 + op_falsy]))
        {
            semsg(_(e_white_space_required_before_and_after_str_at_str),
!                                                    op_falsy ? "??" : "?", p);
            return FAIL;
        }
  
*** ../vim-8.2.2894/src/testdir/test_vim9_expr.vim      2021-05-28 
13:50:13.821107364 +0200
--- src/testdir/test_vim9_expr.vim      2021-05-28 17:49:52.452635120 +0200
***************
*** 172,182 ****
--- 172,194 ----
    call CheckDefAndScriptFailure(["var x = 1? 'one' : 'two'"], msg, 1)
    call CheckDefAndScriptFailure(["var x = 1 ?'one' : 'two'"], msg, 1)
    call CheckDefAndScriptFailure(["var x = 1?'one' : 'two'"], msg, 1)
+   let lines =<< trim END
+     var x = 1
+      ?'one' : 'two'
+      # comment
+   END
+   call CheckDefAndScriptFailure(lines, 'E1004: White space required before 
and after ''?'' at "?''one'' : ''two''"', 2)
  
    let msg = "White space required before and after ':'"
    call CheckDefAndScriptFailure(["var x = 1 ? 'one': 'two'"], msg, 1)
    call CheckDefAndScriptFailure(["var x = 1 ? 'one' :'two'"], msg, 1)
    call CheckDefAndScriptFailure(["var x = 1 ? 'one':'two'"], msg, 1)
+   let lines =<< trim END
+     var x = 1 ? 'one'
+           :'two'
+           # Comment
+   END
+   call CheckDefAndScriptFailure(lines, 'E1004: White space required before 
and after '':'' at ":''two''"', 2)
  
    call CheckDefAndScriptFailure(["var x = 'x' ? 'one' : 'two'"], 'E1135:', 1)
    call CheckDefAndScriptFailure(["var x = 0z1234 ? 'one' : 'two'"], 'E974:', 
1)
***************
*** 229,234 ****
--- 241,252 ----
    call CheckDefAndScriptFailure(["var x = 1?? 'one' : 'two'"], msg, 1)
    call CheckDefAndScriptFailure(["var x = 1 ??'one' : 'two'"], msg, 1)
    call CheckDefAndScriptFailure(["var x = 1??'one' : 'two'"], msg, 1)
+   lines =<< trim END
+     var x = 1
+       ??'one' : 'two'
+       #comment
+   END
+   CheckDefAndScriptFailure(lines, 'E1004: White space required before and 
after ''??'' at "??''one'' : ''two''"', 2)
  enddef
  
  def Record(val: any): any
***************
*** 376,381 ****
--- 394,406 ----
  
    call CheckDefAndScriptFailure2(["var x = [] || false"], 'E1012: Type 
mismatch; expected bool but got list<unknown>', 'E745:', 1)
  
+   var lines =<< trim END
+     vim9script
+     echo false
+       ||true
+     # comment
+   END
+   CheckScriptFailure(lines, 'E1004: White space required before and after 
''||'' at "||true"', 3)
  enddef
  
  " test &&
***************
*** 476,488 ****
    CheckDefAndScriptFailure(["var x = 1&&2"], msg, 1)
    CheckDefAndScriptFailure(["var x = 1 &&2"], msg, 1)
    CheckDefAndScriptFailure(["var x = 1&& 2"], msg, 1)
  
    g:vals = []
    CheckDefAndScriptFailure2(["if 'yes' && 0", 'echo 0', 'endif'], 'E1012: 
Type mismatch; expected bool but got string', 'E1135: Using a String as a 
Bool', 1)
  
    CheckDefExecAndScriptFailure(['assert_equal(false, Record(1) && Record(4) 
&& Record(0))'], 'E1023: Using a Number as a Bool: 4', 1)
  
!   var lines =<< trim END
        if 3
            && true
        endif
--- 501,519 ----
    CheckDefAndScriptFailure(["var x = 1&&2"], msg, 1)
    CheckDefAndScriptFailure(["var x = 1 &&2"], msg, 1)
    CheckDefAndScriptFailure(["var x = 1&& 2"], msg, 1)
+   var lines =<< trim END
+     var x = 1
+       &&2
+     # comment
+   END
+   CheckDefAndScriptFailure(lines, 'E1004: White space required before and 
after ''&&'' at "&&2"', 2)
  
    g:vals = []
    CheckDefAndScriptFailure2(["if 'yes' && 0", 'echo 0', 'endif'], 'E1012: 
Type mismatch; expected bool but got string', 'E1135: Using a String as a 
Bool', 1)
  
    CheckDefExecAndScriptFailure(['assert_equal(false, Record(1) && Record(4) 
&& Record(0))'], 'E1023: Using a Number as a Bool: 4', 1)
  
!   lines =<< trim END
        if 3
            && true
        endif
***************
*** 976,981 ****
--- 1007,1018 ----
    END
    CheckDefAndScriptFailure(lines, 'E1004:', 1)
  
+   for op in ['==', '>', '>=', '<', '<=', '=~', '!~', 'is', 'isnot']
+     lines = ["echo 'aaa'", op .. "'bbb'", '# comment']
+     var msg = printf("E1004: White space required before and after '%s'", op)
+     CheckDefAndScriptFailure(lines, msg, 2)
+   endfor
+ 
    lines =<< trim END
      echo len('xxx') == 3
    END
***************
*** 1264,1269 ****
--- 1301,1312 ----
        bwipe!
    END
    CheckDefAndScriptFailure(lines, "E1004: White space required before and 
after '/' at \"/pattern", 3)
+ 
+   for op in ['+', '-']
+     lines = ['var x = 1', op .. '2', '# comment']
+     var msg = printf("E1004: White space required before and after '%s' at 
\"%s2\"", op, op)
+     CheckDefAndScriptFailure(lines, msg, 2)
+   endfor
  enddef
  
  def Test_expr5_vim9script_channel()
***************
*** 1545,1550 ****
--- 1588,1599 ----
    if has('float')
      call CheckDefAndScriptFailure2(["var x = 0.7[1]"], 'E1107:', 'E806:', 1)
    endif
+ 
+   for op in ['*', '/', '%']
+     let lines = ['var x = 1', op .. '2', '# comment']
+     let msg = printf("E1004: White space required before and after '%s' at 
\"%s2\"", op, op)
+     call CheckDefAndScriptFailure(lines, msg, 2)
+   endfor
  endfunc
  
  func Test_expr6_float_fails()
*** ../vim-8.2.2894/src/version.c       2021-05-28 15:49:29.254504153 +0200
--- src/version.c       2021-05-28 17:35:57.187034814 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2895,
  /**/

-- 
CRONE:  Who sent you?
ARTHUR: The Knights Who Say Ni!
CRONE:  Aaaagh!  (she looks around in rear) No!  We have no shrubberies here.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202105281553.14SFrBTK1281601%40masaka.moolenaar.net.

Raspunde prin e-mail lui