Patch 9.0.0299
Problem:    Error messages for setcmdline() could be better.
Solution:   Use more specific error messages. (Yegappan Lakshmanan,
            closes #10995)
Files:      src/ex_getln.c, src/testdir/test_cmdline.vim,
            src/testdir/test_vim9_builtin.vim


*** ../vim-9.0.0298/src/ex_getln.c      2022-08-28 12:06:17.812288644 +0100
--- src/ex_getln.c      2022-08-28 17:20:04.812549360 +0100
***************
*** 4272,4282 ****
  {
      int pos = -1;
  
!     if (argvars[0].v_type != VAR_STRING || argvars[0].vval.v_string == NULL)
!     {
!       emsg(_(e_string_required));
        return;
-     }
  
      if (argvars[1].v_type != VAR_UNKNOWN)
      {
--- 4272,4280 ----
  {
      int pos = -1;
  
!     if (check_for_string_arg(argvars, 0) == FAIL
!           || check_for_opt_number_arg(argvars, 1) == FAIL)
        return;
  
      if (argvars[1].v_type != VAR_UNKNOWN)
      {
*** ../vim-9.0.0298/src/testdir/test_cmdline.vim        2022-08-27 
12:22:19.979008597 +0100
--- src/testdir/test_cmdline.vim        2022-08-28 17:20:04.812549360 +0100
***************
*** 3273,3280 ****
      call assert_equal(a:pos, getcmdpos())
  
      call assert_fails('call setcmdline("' .. a:text .. '", -1)', 'E487:')
!     call assert_fails('call setcmdline({}, 0)', 'E928:')
!     call assert_fails('call setcmdline("' .. a:text .. '", {})', 'E728:')
  
      return ''
    endfunc
--- 3273,3280 ----
      call assert_equal(a:pos, getcmdpos())
  
      call assert_fails('call setcmdline("' .. a:text .. '", -1)', 'E487:')
!     call assert_fails('call setcmdline({}, 0)', 'E1174:')
!     call assert_fails('call setcmdline("' .. a:text .. '", {})', 'E1210:')
  
      return ''
    endfunc
*** ../vim-9.0.0298/src/testdir/test_vim9_builtin.vim   2022-08-27 
12:22:19.979008597 +0100
--- src/testdir/test_vim9_builtin.vim   2022-08-28 17:20:04.816549344 +0100
***************
*** 3659,3666 ****
  
  def Test_setcmdline()
    v9.CheckDefAndScriptSuccess(['setcmdline("ls", 2)'])
!   v9.CheckDefAndScriptFailure(['setcmdline(123)'], ['E1013: Argument 1: type 
mismatch, expected string but got number', 'E928: String required'])
!   v9.CheckDefAndScriptFailure(['setcmdline("ls", "x")'], ['E1013: Argument 2: 
type mismatch, expected number but got string', 'E1030: Using a String as a 
Number'])
  enddef
  
  def Test_setcmdpos()
--- 3659,3666 ----
  
  def Test_setcmdline()
    v9.CheckDefAndScriptSuccess(['setcmdline("ls", 2)'])
!   v9.CheckDefAndScriptFailure(['setcmdline(123)'], ['E1013: Argument 1: type 
mismatch, expected string but got number', 'E1174: String required for argument 
1'])
!   v9.CheckDefAndScriptFailure(['setcmdline("ls", "x")'], ['E1013: Argument 2: 
type mismatch, expected number but got string', 'E1210: Number required for 
argument 2'])
  enddef
  
  def Test_setcmdpos()
*** ../vim-9.0.0298/src/version.c       2022-08-28 17:08:14.857917390 +0100
--- src/version.c       2022-08-28 17:24:53.783566102 +0100
***************
*** 709,710 ****
--- 709,712 ----
  {   /* Add new patch number below this line */
+ /**/
+     299,
  /**/

-- 
ERIC IDLE PLAYED: THE DEAD COLLECTOR, MR BINT (A VILLAGE NE'ER-DO -WELL VERY
                  KEEN ON BURNING WITCHES), SIR ROBIN, THE GUARD WHO DOESN'T
                  HICOUGH BUT TRIES TO GET THINGS STRAIGHT, CONCORDE (SIR
                  LAUNCELOT'S TRUSTY STEED), ROGER THE SHRUBBER (A SHRUBBER),
                  BROTHER MAYNARD
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220828162621.955E61C07CD%40moolenaar.net.

Raspunde prin e-mail lui