Patch 8.2.1096

13 views
Skip to first unread message

Bram Moolenaar

unread,
Jun 30, 2020, 7:39:15 AM6/30/20
to vim...@googlegroups.com

Patch 8.2.1096
Problem: Vim9: return type of getqflist() is wrong.
Solution: Let the return type depend on the arguments. Also for
getloclist(). (closes #6367)
Files: src/evalfunc.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.1095/src/evalfunc.c 2020-06-29 19:55:54.885328478 +0200
--- src/evalfunc.c 2020-06-30 13:15:05.045003874 +0200
***************
*** 347,352 ****
--- 347,376 ----
return &t_void;
}

+ /*
+ * Used for getqflist(): returns list if there is no argument, dict if there is
+ * one.
+ */
+ static type_T *
+ ret_list_or_dict_0(int argcount, type_T **argtypes UNUSED)
+ {
+ if (argcount > 0)
+ return &t_dict_any;
+ return &t_list_dict_any;
+ }
+
+ /*
+ * Used for getloclist(): returns list if there is one argument, dict if there
+ * are two.
+ */
+ static type_T *
+ ret_list_or_dict_1(int argcount, type_T **argtypes UNUSED)
+ {
+ if (argcount > 1)
+ return &t_dict_any;
+ return &t_list_dict_any;
+ }
+
static type_T *ret_f_function(int argcount, type_T **argtypes);

/*
***************
*** 588,600 ****
{"getimstatus", 0, 0, 0, ret_number, f_getimstatus},
{"getjumplist", 0, 2, FEARG_1, ret_list_any, f_getjumplist},
{"getline", 1, 2, FEARG_1, ret_f_getline, f_getline},
! {"getloclist", 1, 2, 0, ret_list_dict_any, f_getloclist},
{"getmarklist", 0, 1, FEARG_1, ret_list_dict_any, f_getmarklist},
{"getmatches", 0, 1, 0, ret_list_dict_any, f_getmatches},
{"getmousepos", 0, 0, 0, ret_dict_number, f_getmousepos},
{"getpid", 0, 0, 0, ret_number, f_getpid},
{"getpos", 1, 1, FEARG_1, ret_list_number, f_getpos},
! {"getqflist", 0, 1, 0, ret_list_dict_any, f_getqflist},
{"getreg", 0, 3, FEARG_1, ret_string, f_getreg},
{"getreginfo", 0, 1, FEARG_1, ret_dict_any, f_getreginfo},
{"getregtype", 0, 1, FEARG_1, ret_string, f_getregtype},
--- 612,624 ----
{"getimstatus", 0, 0, 0, ret_number, f_getimstatus},
{"getjumplist", 0, 2, FEARG_1, ret_list_any, f_getjumplist},
{"getline", 1, 2, FEARG_1, ret_f_getline, f_getline},
! {"getloclist", 1, 2, 0, ret_list_or_dict_1, f_getloclist},
{"getmarklist", 0, 1, FEARG_1, ret_list_dict_any, f_getmarklist},
{"getmatches", 0, 1, 0, ret_list_dict_any, f_getmatches},
{"getmousepos", 0, 0, 0, ret_dict_number, f_getmousepos},
{"getpid", 0, 0, 0, ret_number, f_getpid},
{"getpos", 1, 1, FEARG_1, ret_list_number, f_getpos},
! {"getqflist", 0, 1, 0, ret_list_or_dict_0, f_getqflist},
{"getreg", 0, 3, FEARG_1, ret_string, f_getreg},
{"getreginfo", 0, 1, FEARG_1, ret_dict_any, f_getreginfo},
{"getregtype", 0, 1, FEARG_1, ret_string, f_getregtype},
*** ../vim-8.2.1095/src/testdir/test_vim9_func.vim 2020-06-22 19:38:59.928402805 +0200
--- src/testdir/test_vim9_func.vim 2020-06-30 13:20:31.519608201 +0200
***************
*** 837,842 ****
--- 837,858 ----
res = [1, 2, 3]->sort()
enddef

+ def Test_getqflist_return_type()
+ let l = getqflist()
+ assert_equal([], l)
+
+ let d = getqflist(#{items: 0})
+ assert_equal(#{items: []}, d)
+ enddef
+
+ def Test_getloclist_return_type()
+ let l = getloclist(1)
+ assert_equal([], l)
+
+ let d = getloclist(1, #{items: 0})
+ assert_equal(#{items: []}, d)
+ enddef
+
def Line_continuation_in_def(dir: string = ''): string
let path: string = empty(dir)
\ ? 'empty'
*** ../vim-8.2.1095/src/version.c 2020-06-29 23:18:39.731914331 +0200
--- src/version.c 2020-06-30 13:19:50.459785376 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1096,
/**/

--
To keep milk from turning sour: Keep it in the cow.

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///

Yegappan Lakshmanan

unread,
Jun 30, 2020, 1:24:25 PM6/30/20
to vim_dev
Hi,

On Tue, Jun 30, 2020 at 4:39 AM Bram Moolenaar <Br...@moolenaar.net> wrote:

Patch 8.2.1096
Problem:    Vim9: return type of getqflist() is wrong.
Solution:   Let the return type depend on the arguments.  Also for
            getloclist(). (closes #6367)
Files:      src/evalfunc.c, src/testdir/test_vim9_func.vim


I am attaching an update to eval.txt to clarify the different return values.

- Yegappan
 
setqflist.diff

Bram Moolenaar

unread,
Jun 30, 2020, 1:58:41 PM6/30/20
to vim...@googlegroups.com, Yegappan Lakshmanan
Thanks. However, in the explanation of a function we don't use two
separate lines for the same function with different arguments.
Otherwise the user would need to check if there is another line for the
function with different arguments, which it might not be visible in a
smaller window.

--
System administrators are just like women: You can't live with them and you
can't live without them.

Yegappan Lakshmanan

unread,
Jun 30, 2020, 2:09:27 PM6/30/20
to Bram Moolenaar, vim_dev
Hi Bram,

On Tue, Jun 30, 2020 at 10:58 AM Bram Moolenaar <Br...@moolenaar.net> wrote:

Yegappan wrote:

> On Tue, Jun 30, 2020 at 4:39 AM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
> >
> > Patch 8.2.1096
> > Problem:    Vim9: return type of getqflist() is wrong.
> > Solution:   Let the return type depend on the arguments.  Also for
> >             getloclist(). (closes #6367)
> > Files:      src/evalfunc.c, src/testdir/test_vim9_func.vim
> >
> >
> I am attaching an update to eval.txt to clarify the different return values.

Thanks.  However, in the explanation of a function we don't use two
separate lines for the same function with different arguments.
Otherwise the user would need to check if there is another line for the
function with different arguments, which it might not be visible in a
smaller window.


We do have a precedent with the help for the get() function.

Regards,
Yegappan
 

Bram Moolenaar

unread,
Jun 30, 2020, 2:53:12 PM6/30/20
to vim...@googlegroups.com, Yegappan Lakshmanan

Yegappan wrote:

> > > On Tue, Jun 30, 2020 at 4:39 AM Bram Moolenaar <Br...@moolenaar.net>
> > wrote:
> > >
> > > >
> > > > Patch 8.2.1096
> > > > Problem: Vim9: return type of getqflist() is wrong.
> > > > Solution: Let the return type depend on the arguments. Also for
> > > > getloclist(). (closes #6367)
> > > > Files: src/evalfunc.c, src/testdir/test_vim9_func.vim
> > > >
> > > >
> > > I am attaching an update to eval.txt to clarify the different return
> > values.
> >
> > Thanks. However, in the explanation of a function we don't use two
> > separate lines for the same function with different arguments.
> > Otherwise the user would need to check if there is another line for the
> > function with different arguments, which it might not be visible in a
> > smaller window.
>
> We do have a precedent with the help for the get() function.

OK, that's true. And it's hard to change that one without making it
hard to read. But let's not make that the normal way.

--
ARTHUR: It is I, Arthur, son of Uther Pendragon, from the castle of Camelot.
King of all Britons, defeator of the Saxons, sovereign of all England!
[Pause]
SOLDIER: Get away!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Reply all
Reply to author
Forward
0 new messages