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:
parent
6c391a74fe
commit
efc084e335
@ -1217,6 +1217,7 @@ list_copy(list_T *orig, int deep, int copyID)
|
|||||||
copy = list_alloc();
|
copy = list_alloc();
|
||||||
if (copy != NULL)
|
if (copy != NULL)
|
||||||
{
|
{
|
||||||
|
copy->lv_type = orig->lv_type;
|
||||||
if (copyID != 0)
|
if (copyID != 0)
|
||||||
{
|
{
|
||||||
// Do this before adding the items, because one of the items may
|
// Do this before adding the items, because one of the items may
|
||||||
|
@ -438,6 +438,29 @@ def Test_return_invalid()
|
|||||||
CheckScriptFailure(lines, 'E1010:')
|
CheckScriptFailure(lines, 'E1010:')
|
||||||
enddef
|
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()
|
func Increment()
|
||||||
let g:counter += 1
|
let g:counter += 1
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3422,
|
||||||
/**/
|
/**/
|
||||||
3421,
|
3421,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user