Patch 8.2.3422
Problem: Vim9: no failure if return type differs from returned variable.
Solution: Copy type when copying a list. (closes #8847)
Files: src/list.c, src/testdir/test_vim9_func.vim
*** ../vim-8.2.3421/src/list.c 2021-08-13 18:19:54.678450486 +0200
--- src/list.c 2021-09-09 22:17:05.250139678 +0200
***************
*** 1217,1222 ****
--- 1217,1223 ----
copy = list_alloc();
if (copy != NULL)
{
+ copy->lv_type = orig->lv_type;
if (copyID != 0)
{
// Do this before adding the items, because one of the items may
*** ../vim-8.2.3421/src/testdir/test_vim9_func.vim 2021-09-05
16:36:20.239647841 +0200
--- src/testdir/test_vim9_func.vim 2021-09-09 22:09:23.854887658 +0200
***************
*** 438,443 ****
--- 438,466 ----
CheckScriptFailure(lines, 'E1010:')
enddef
+ def Test_return_list_any()
+ var lines =<< trim END
+ vim9script
+ def Func(): list<string>
+ var l: list<any>
+ l->add('string')
+ return l
+ enddef
+ echo Func()
+ END
+ CheckScriptFailure(lines, 'E1012:')
+ lines =<< trim END
+ vim9script
+ def Func(): list<string>
+ var l: list<any>
+ l += ['string']
+ return l
+ enddef
+ echo Func()
+ END
+ CheckScriptFailure(lines, 'E1012:')
+ enddef
+
func Increment()
let g:counter += 1
endfunc
*** ../vim-8.2.3421/src/version.c 2021-09-09 20:45:30.258411566 +0200
--- src/version.c 2021-09-09 21:59:38.355950708 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3422,
/**/
--
hundred-and-one symptoms of being an internet addict:
19. All of your friends have an @ in their names.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ 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/202109092031.189KVH5h148086%40masaka.moolenaar.net.