• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisionb5d68d8a51879c52a3101a48df495dd22fa610ba (tree)
Zeit2020-10-18 02:30:05
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.1858: Vim9: filter functions return number instead of bool

Commit: https://github.com/vim/vim/commit/403dc31f5a03b5858f62e72c3407ffaf827b3005
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 17 19:29:51 2020 +0200

patch 8.2.1858: Vim9: filter functions return number instead of bool
Problem: Vim9: filter functions return number instead of bool.
Solution: Return v:true instead of one. (closes https://github.com/vim/vim/issues/7144)

Ändern Zusammenfassung

Diff

diff -r 398e92912dcb -r b5d68d8a5187 src/evalfunc.c
--- a/src/evalfunc.c Sat Oct 17 19:00:06 2020 +0200
+++ b/src/evalfunc.c Sat Oct 17 19:30:05 2020 +0200
@@ -270,6 +270,11 @@
270270 return &t_any;
271271 }
272272 static type_T *
273+ret_bool(int argcount UNUSED, type_T **argtypes UNUSED)
274+{
275+ return &t_bool;
276+}
277+ static type_T *
273278 ret_number(int argcount UNUSED, type_T **argtypes UNUSED)
274279 {
275280 return &t_number;
@@ -793,8 +798,8 @@
793798 {"popup_close", 1, 2, FEARG_1, ret_void, PROP_FUNC(f_popup_close)},
794799 {"popup_create", 2, 2, FEARG_1, ret_number, PROP_FUNC(f_popup_create)},
795800 {"popup_dialog", 2, 2, FEARG_1, ret_number, PROP_FUNC(f_popup_dialog)},
796- {"popup_filter_menu", 2, 2, 0, ret_number, PROP_FUNC(f_popup_filter_menu)},
797- {"popup_filter_yesno", 2, 2, 0, ret_number, PROP_FUNC(f_popup_filter_yesno)},
801+ {"popup_filter_menu", 2, 2, 0, ret_bool, PROP_FUNC(f_popup_filter_menu)},
802+ {"popup_filter_yesno", 2, 2, 0, ret_bool, PROP_FUNC(f_popup_filter_yesno)},
798803 {"popup_findinfo", 0, 0, 0, ret_number, PROP_FUNC(f_popup_findinfo)},
799804 {"popup_findpreview", 0, 0, 0, ret_number, PROP_FUNC(f_popup_findpreview)},
800805 {"popup_getoptions", 1, 1, FEARG_1, ret_dict_any, PROP_FUNC(f_popup_getoptions)},
diff -r 398e92912dcb -r b5d68d8a5187 src/popupwin.c
--- a/src/popupwin.c Sat Oct 17 19:00:06 2020 +0200
+++ b/src/popupwin.c Sat Oct 17 19:30:05 2020 +0200
@@ -2375,7 +2375,8 @@
23752375 c = TO_SPECIAL(key[1], key[2]);
23762376
23772377 // consume all keys until done
2378- rettv->vval.v_number = 1;
2378+ rettv->v_type = VAR_BOOL;
2379+ rettv->vval.v_number = VVAL_TRUE;
23792380 res.v_type = VAR_NUMBER;
23802381
23812382 old_lnum = wp->w_cursor.lnum;
@@ -2429,7 +2430,8 @@
24292430 c = TO_SPECIAL(key[1], key[2]);
24302431
24312432 // consume all keys until done
2432- rettv->vval.v_number = 1;
2433+ rettv->v_type = VAR_BOOL;
2434+ rettv->vval.v_number = VVAL_TRUE;
24332435
24342436 if (c == 'y' || c == 'Y')
24352437 res.vval.v_number = 1;
diff -r 398e92912dcb -r b5d68d8a5187 src/testdir/test_vim9_func.vim
--- a/src/testdir/test_vim9_func.vim Sat Oct 17 19:00:06 2020 +0200
+++ b/src/testdir/test_vim9_func.vim Sat Oct 17 19:30:05 2020 +0200
@@ -94,6 +94,20 @@
9494 'enddef'], 'E1095:')
9595 enddef
9696
97+def Test_return_bool()
98+ var lines =<< trim END
99+ vim9script
100+ def MenuFilter(id: number, key: string): bool
101+ return popup_filter_menu(id, key)
102+ enddef
103+ def YesnoFilter(id: number, key: string): bool
104+ return popup_filter_yesno(id, key)
105+ enddef
106+ defcompile
107+ END
108+ CheckScriptSuccess(lines)
109+enddef
110+
97111 let s:nothing = 0
98112 def ReturnNothing()
99113 s:nothing = 1
diff -r 398e92912dcb -r b5d68d8a5187 src/version.c
--- a/src/version.c Sat Oct 17 19:00:06 2020 +0200
+++ b/src/version.c Sat Oct 17 19:30:05 2020 +0200
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 1858,
755+/**/
754756 1857,
755757 /**/
756758 1856,
Show on old repository browser