Patch 8.2.1550
Problem:    Vim9: bufname('%') gives an error.
Solution:   Only give an error for wrong argument type. (closes #6807)
Files:      src/evalbuffer.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.1549/src/evalbuffer.c    2020-08-17 22:21:32.751993070 +0200
--- src/evalbuffer.c    2020-08-30 21:22:18.988053933 +0200
***************
*** 359,373 ****
  f_bufname(typval_T *argvars, typval_T *rettv)
  {
      buf_T     *buf;
  
!     if (argvars[0].v_type == VAR_UNKNOWN)
        buf = curbuf;
      else
      {
-       (void)tv_get_number(&argvars[0]);       // issue errmsg if type error
        ++emsg_off;
!       buf = tv_get_buf(&argvars[0], FALSE);
        --emsg_off;
      }
      rettv->v_type = VAR_STRING;
      if (buf != NULL && buf->b_fname != NULL)
--- 359,378 ----
  f_bufname(typval_T *argvars, typval_T *rettv)
  {
      buf_T     *buf;
+     typval_T  *tv = &argvars[0];
  
!     if (tv->v_type == VAR_UNKNOWN)
        buf = curbuf;
      else
      {
        ++emsg_off;
!       buf = tv_get_buf(tv, FALSE);
        --emsg_off;
+       if (buf == NULL
+               && tv->v_type != VAR_NUMBER
+               && tv->v_type != VAR_STRING)
+           // issue errmsg for type error
+           (void)tv_get_number(tv);
      }
      rettv->v_type = VAR_STRING;
      if (buf != NULL && buf->b_fname != NULL)
*** ../vim-8.2.1549/src/testdir/test_vim9_func.vim      2020-08-28 
17:19:03.831887039 +0200
--- src/testdir/test_vim9_func.vim      2020-08-30 21:21:41.696166888 +0200
***************
*** 1435,1440 ****
--- 1435,1448 ----
    assert_equal(reginfo, getreginfo('a'))
  enddef 
  
+ def Test_bufname()
+   split SomeFile
+   assert_equal('SomeFile', bufname('%'))
+   edit OtherFile
+   assert_equal('SomeFile', bufname('#'))
+   close
+ enddef
+ 
  def Fibonacci(n: number): number
    if n < 2
      return n
*** ../vim-8.2.1549/src/version.c       2020-08-30 20:46:34.470356761 +0200
--- src/version.c       2020-08-30 21:26:04.835368279 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1550,
  /**/

-- 
You had connectors?  Eeee, when I were a lad we 'ad to carry the
bits between the computer and the terminal with a spoon...

 /// 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/202008301927.07UJRdAP2881084%40masaka.moolenaar.net.

Raspunde prin e-mail lui