0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.3422: Vim9: no failure if return type differs from returned var

Problem:    Vim9: no failure if return type differs from returned variable.
Solution:   Copy type when copying a list. (closes #8847)
This commit is contained in:
Bram Moolenaar 2021-09-09 22:30:52 +02:00
parent 6c391a74fe
commit efc084e335
3 changed files with 26 additions and 0 deletions

View File

@ -1217,6 +1217,7 @@ list_copy(list_T *orig, int deep, int copyID)
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

View File

@ -438,6 +438,29 @@ def Test_return_invalid()
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

View File

@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3422,
/**/
3421,
/**/