Patch 8.2.3144
Problem:    Vim9: no error when using an invalid value for a line number.
Solution:   Give an error if the string value is not recognized.
            (closes #8536)
Files:      src/errors.h, src/eval.c, src/testdir/test_vim9_builtin.vim


*** ../vim-8.2.3143/src/errors.h        2021-07-11 14:28:19.943563551 +0200
--- src/errors.h        2021-07-11 15:48:15.029198766 +0200
***************
*** 498,500 ****
--- 498,502 ----
        INIT(= N_("E1207: Expression without an effect: %s"));
  EXTERN char e_complete_used_without_nargs[]
        INIT(= N_("E1208: -complete used without -nargs"));
+ EXTERN char e_invalid_value_for_line_number_str[]
+       INIT(= N_("E1209: Invalid value for a line number: \"%s\""));
*** ../vim-8.2.3143/src/eval.c  2021-07-10 21:28:55.327050110 +0200
--- src/eval.c  2021-07-11 15:44:50.745502449 +0200
***************
*** 5376,5381 ****
--- 5376,5383 ----
        }
        return &pos;
      }
+     if (in_vim9script())
+       semsg(_(e_invalid_value_for_line_number_str), name);
      return NULL;
  }
  
*** ../vim-8.2.3143/src/testdir/test_vim9_builtin.vim   2021-07-11 
14:55:45.253356763 +0200
--- src/testdir/test_vim9_builtin.vim   2021-07-11 16:00:04.168221858 +0200
***************
*** 474,480 ****
    var lines =<< trim END
      cursor('2', 1)
    END
!   CheckDefExecAndScriptFailure(lines, 'E475:')
  enddef
  
  def Test_debugbreak()
--- 474,480 ----
    var lines =<< trim END
      cursor('2', 1)
    END
!   CheckDefExecAndScriptFailure(lines, 'E1209:')
  enddef
  
  def Test_debugbreak()
***************
*** 1036,1041 ****
--- 1036,1060 ----
    CheckDefFailure(['getjumplist(1, "x")'], 'E1013: Argument 2: type mismatch, 
expected number but got string')
  enddef
  
+ def Test_getline()
+   var lines =<< trim END
+       new
+       setline(1, ['hello', 'there', 'again'])
+       assert_equal('hello', getline(1))
+       assert_equal('hello', getline('.'))
+ 
+       normal 2Gvjv
+       assert_equal('there', getline("'<"))
+       assert_equal('again', getline("'>"))
+   END
+   CheckDefAndScriptSuccess(lines)
+ 
+   lines =<< trim END
+       echo getline('1')
+   END
+   CheckDefExecAndScriptFailure(lines, 'E1209:')
+ enddef
+ 
  def Test_getmarklist()
    CheckDefFailure(['getmarklist([])'], 'E1013: Argument 1: type mismatch, 
expected string but got list<unknown>')
    assert_equal([], getmarklist(10000))
***************
*** 1049,1055 ****
  def Test_getpos()
    CheckDefFailure(['getpos(10)'], 'E1013: Argument 1: type mismatch, expected 
string but got number')
    assert_equal([0, 1, 1, 0], getpos('.'))
!   assert_equal([0, 0, 0, 0], getpos('a'))
  enddef
  
  def Test_getqflist()
--- 1068,1074 ----
  def Test_getpos()
    CheckDefFailure(['getpos(10)'], 'E1013: Argument 1: type mismatch, expected 
string but got number')
    assert_equal([0, 1, 1, 0], getpos('.'))
!   CheckDefExecFailure(['getpos("a")'], 'E1209:')
  enddef
  
  def Test_getqflist()
*** ../vim-8.2.3143/src/version.c       2021-07-11 15:26:09.943038696 +0200
--- src/version.c       2021-07-11 15:46:12.329381494 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3144,
  /**/

-- 
Amnesia is one of my favorite words, but I forgot what it means.

 /// 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/202107111402.16BE2bW3831593%40masaka.moolenaar.net.

Raspunde prin e-mail lui