Patch 8.2.1858
Problem:    Vim9: filter functions return number instead of bool.
Solution:   Return v:true instead of one. (closes #7144)
Files:      src/popupwin.c, src/evalfunc.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.1857/src/popupwin.c      2020-10-15 19:10:53.203606791 +0200
--- src/popupwin.c      2020-10-17 19:26:23.487503499 +0200
***************
*** 2375,2381 ****
        c = TO_SPECIAL(key[1], key[2]);
  
      // consume all keys until done
!     rettv->vval.v_number = 1;
      res.v_type = VAR_NUMBER;
  
      old_lnum = wp->w_cursor.lnum;
--- 2375,2382 ----
        c = TO_SPECIAL(key[1], key[2]);
  
      // consume all keys until done
!     rettv->v_type = VAR_BOOL;
!     rettv->vval.v_number = VVAL_TRUE;
      res.v_type = VAR_NUMBER;
  
      old_lnum = wp->w_cursor.lnum;
***************
*** 2429,2435 ****
        c = TO_SPECIAL(key[1], key[2]);
  
      // consume all keys until done
!     rettv->vval.v_number = 1;
  
      if (c == 'y' || c == 'Y')
        res.vval.v_number = 1;
--- 2430,2437 ----
        c = TO_SPECIAL(key[1], key[2]);
  
      // consume all keys until done
!     rettv->v_type = VAR_BOOL;
!     rettv->vval.v_number = VVAL_TRUE;
  
      if (c == 'y' || c == 'Y')
        res.vval.v_number = 1;
*** ../vim-8.2.1857/src/evalfunc.c      2020-09-29 20:59:13.561602886 +0200
--- src/evalfunc.c      2020-10-17 19:25:57.347576064 +0200
***************
*** 270,275 ****
--- 270,280 ----
      return &t_any;
  }
      static type_T *
+ ret_bool(int argcount UNUSED, type_T **argtypes UNUSED)
+ {
+     return &t_bool;
+ }
+     static type_T *
  ret_number(int argcount UNUSED, type_T **argtypes UNUSED)
  {
      return &t_number;
***************
*** 793,800 ****
      {"popup_close",   1, 2, FEARG_1,    ret_void,     
PROP_FUNC(f_popup_close)},
      {"popup_create",  2, 2, FEARG_1,    ret_number,   
PROP_FUNC(f_popup_create)},
      {"popup_dialog",  2, 2, FEARG_1,    ret_number,   
PROP_FUNC(f_popup_dialog)},
!     {"popup_filter_menu", 2, 2, 0,      ret_number,   
PROP_FUNC(f_popup_filter_menu)},
!     {"popup_filter_yesno", 2, 2, 0,     ret_number,   
PROP_FUNC(f_popup_filter_yesno)},
      {"popup_findinfo",        0, 0, 0,          ret_number,   
PROP_FUNC(f_popup_findinfo)},
      {"popup_findpreview", 0, 0, 0,      ret_number,   
PROP_FUNC(f_popup_findpreview)},
      {"popup_getoptions", 1, 1, FEARG_1,         ret_dict_any, 
PROP_FUNC(f_popup_getoptions)},
--- 798,805 ----
      {"popup_close",   1, 2, FEARG_1,    ret_void,     
PROP_FUNC(f_popup_close)},
      {"popup_create",  2, 2, FEARG_1,    ret_number,   
PROP_FUNC(f_popup_create)},
      {"popup_dialog",  2, 2, FEARG_1,    ret_number,   
PROP_FUNC(f_popup_dialog)},
!     {"popup_filter_menu", 2, 2, 0,      ret_bool,     
PROP_FUNC(f_popup_filter_menu)},
!     {"popup_filter_yesno", 2, 2, 0,     ret_bool,     
PROP_FUNC(f_popup_filter_yesno)},
      {"popup_findinfo",        0, 0, 0,          ret_number,   
PROP_FUNC(f_popup_findinfo)},
      {"popup_findpreview", 0, 0, 0,      ret_number,   
PROP_FUNC(f_popup_findpreview)},
      {"popup_getoptions", 1, 1, FEARG_1,         ret_dict_any, 
PROP_FUNC(f_popup_getoptions)},
*** ../vim-8.2.1857/src/testdir/test_vim9_func.vim      2020-10-13 
18:38:07.432468135 +0200
--- src/testdir/test_vim9_func.vim      2020-10-17 19:25:37.459631249 +0200
***************
*** 94,99 ****
--- 94,113 ----
                     'enddef'], 'E1095:')
  enddef
  
+ def Test_return_bool()
+   var lines =<< trim END
+       vim9script
+       def MenuFilter(id: number, key: string): bool
+         return popup_filter_menu(id, key)
+       enddef
+       def YesnoFilter(id: number, key: string): bool
+         return popup_filter_yesno(id, key)
+       enddef
+       defcompile
+   END
+   CheckScriptSuccess(lines)
+ enddef
+ 
  let s:nothing = 0
  def ReturnNothing()
    s:nothing = 1
*** ../vim-8.2.1857/src/version.c       2020-10-17 18:51:48.501219339 +0200
--- src/version.c       2020-10-17 19:20:25.516492024 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1858,
  /**/

-- 
>From "know your smileys":
 8-O    "Omigod!!" (done "rm -rf *" ?)

 /// 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/202010171730.09HHUMQK681622%40masaka.moolenaar.net.

Raspunde prin e-mail lui