Patch 8.2.1003
Problem:    Vim9: return type of sort() is too generic.
Solution:   Get type from the first argument. (closes #6292)
Files:      src/evalfunc.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.1002/src/evalfunc.c      2020-06-16 20:03:38.747351038 +0200
--- src/evalfunc.c      2020-06-18 18:44:36.934055203 +0200
***************
*** 339,344 ****
--- 339,352 ----
      return &t_job;
  }
  
+     static type_T *
+ ret_first_arg(int argcount, type_T **argtypes)
+ {
+     if (argcount > 0)
+       return argtypes[0];
+     return &t_void;
+ }
+ 
  static type_T *ret_f_function(int argcount, type_T **argtypes);
  
  /*
***************
*** 849,855 ****
      {"simplify",      1, 1, FEARG_1,    ret_string,   f_simplify},
      {"sin",           1, 1, FEARG_1,    ret_float,    FLOAT_FUNC(f_sin)},
      {"sinh",          1, 1, FEARG_1,    ret_float,    FLOAT_FUNC(f_sinh)},
!     {"sort",          1, 3, FEARG_1,    ret_list_any, f_sort},
      {"sound_clear",   0, 0, 0,          ret_void,     
SOUND_FUNC(f_sound_clear)},
      {"sound_playevent",       1, 2, FEARG_1,    ret_number,   
SOUND_FUNC(f_sound_playevent)},
      {"sound_playfile",        1, 2, FEARG_1,    ret_number,   
SOUND_FUNC(f_sound_playfile)},
--- 857,863 ----
      {"simplify",      1, 1, FEARG_1,    ret_string,   f_simplify},
      {"sin",           1, 1, FEARG_1,    ret_float,    FLOAT_FUNC(f_sin)},
      {"sinh",          1, 1, FEARG_1,    ret_float,    FLOAT_FUNC(f_sinh)},
!     {"sort",          1, 3, FEARG_1,    ret_first_arg, f_sort},
      {"sound_clear",   0, 0, 0,          ret_void,     
SOUND_FUNC(f_sound_clear)},
      {"sound_playevent",       1, 2, FEARG_1,    ret_number,   
SOUND_FUNC(f_sound_playevent)},
      {"sound_playfile",        1, 2, FEARG_1,    ret_number,   
SOUND_FUNC(f_sound_playfile)},
*** ../vim-8.2.1002/src/testdir/test_vim9_func.vim      2020-05-24 
23:45:20.529386094 +0200
--- src/testdir/test_vim9_func.vim      2020-06-18 18:44:21.982088566 +0200
***************
*** 807,811 ****
--- 807,816 ----
    assert_equal('sometext', GetResult(g:Ref))
  enddef
  
+ def Test_sort_return_type()
+   let res: list<number>
+   res = [1, 2, 3]->sort()
+ enddef
+ 
  
  " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.1002/src/version.c       2020-06-18 18:33:56.419365443 +0200
--- src/version.c       2020-06-18 18:45:22.373953310 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1003,
  /**/

-- 
There are three kinds of people: Those who can count & those who can't.

 /// 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/202006181646.05IGkWTH406661%40masaka.moolenaar.net.

Raspunde prin e-mail lui