Compare commits

...

3 Commits

Author SHA1 Message Date
Bram Moolenaar
97f227d9c9 patch 8.2.3105: Vim9: type of partial is wrong when it has arguments
Problem:    Vim9: type of partial is wrong when it has arguments.
Solution:   Subtract arguments from the count. (issue #8492)
2021-07-04 20:20:52 +02:00
Bram Moolenaar
b7480cd893 patch 8.2.3104: Vim9: unspecified function type causes type error
Problem:    Vim9: unspecified function type causes type error.
Solution:   Don't check type when min_argcount is negative. (issue #8492)
2021-07-04 18:28:15 +02:00
Bram Moolenaar
f33cae6050 patch 8.2.3103: swap test may fail on some systems
Problem:    Swap test may fail on some systems when jobs take longer to exit.
Solution:   Use different file names.
2021-07-04 17:36:54 +02:00
6 changed files with 57 additions and 14 deletions

View File

@@ -421,7 +421,7 @@ EXTERN type_T t_channel INIT6(VAR_CHANNEL, 0, 0, TTFLAG_STATIC, NULL, NULL);
// Special value used for @#.
EXTERN type_T t_number_or_string INIT6(VAR_STRING, 0, 0, TTFLAG_STATIC, NULL, NULL);
EXTERN type_T t_func_unknown INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_unknown, NULL);
EXTERN type_T t_func_unknown INIT6(VAR_FUNC, -1, -1, TTFLAG_STATIC, &t_unknown, NULL);
EXTERN type_T t_func_void INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_void, NULL);
EXTERN type_T t_func_any INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_any, NULL);
EXTERN type_T t_func_number INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_number, NULL);

View File

@@ -502,18 +502,18 @@ endfunc
" Test for renaming a buffer when the swap file is deleted out-of-band
func Test_missing_swap_file()
CheckUnix
new Xfile1
new Xfile2
call delete(swapname(''))
call assert_fails('file Xfile2', 'E301:')
call assert_equal('Xfile2', bufname())
call assert_true(bufexists('Xfile1'))
call assert_fails('file Xfile3', 'E301:')
call assert_equal('Xfile3', bufname())
call assert_true(bufexists('Xfile2'))
call assert_true(bufexists('Xfile3'))
%bw!
endfunc
" Test for :preserve command
func Test_preserve()
new Xfile1
new Xfile4
setlocal noswapfile
call assert_fails('preserve', 'E313:')
bw!
@@ -521,8 +521,8 @@ endfunc
" Test for the v:swapchoice variable
func Test_swapchoice()
call writefile(['aaa', 'bbb'], 'Xfile1')
edit Xfile1
call writefile(['aaa', 'bbb'], 'Xfile5')
edit Xfile5
preserve
let swapfname = swapname('')
let b = readblob(swapfname)
@@ -536,7 +536,7 @@ func Test_swapchoice()
autocmd!
autocmd SwapExists * let v:swapchoice = 'o'
augroup END
edit Xfile1
edit Xfile5
call assert_true(&readonly)
call assert_equal(['aaa', 'bbb'], getline(1, '$'))
%bw!
@@ -548,11 +548,11 @@ func Test_swapchoice()
autocmd SwapExists * let v:swapchoice = 'a'
augroup END
try
edit Xfile1
edit Xfile5
catch /^Vim:Interrupt$/
endtry
call assert_equal('', @%)
call assert_true(bufexists('Xfile1'))
call assert_true(bufexists('Xfile5'))
%bw!
call assert_true(filereadable(swapfname))
@@ -561,12 +561,12 @@ func Test_swapchoice()
autocmd!
autocmd SwapExists * let v:swapchoice = 'd'
augroup END
edit Xfile1
call assert_equal('Xfile1', @%)
edit Xfile5
call assert_equal('Xfile5', @%)
%bw!
call assert_false(filereadable(swapfname))
call delete('Xfile1')
call delete('Xfile5')
call delete(swapfname)
augroup test_swapchoice
autocmd!

View File

@@ -661,6 +661,18 @@ def Test_assignment_list()
CheckDefExecAndScriptFailure(lines, 'E1012:', 5)
enddef
def PartFuncBool(b: bool): string
return 'done'
enddef
def Test_assignment_partial()
var lines =<< trim END
var Partial: func(): string = function(PartFuncBool, [true])
assert_equal('done', Partial())
END
CheckDefAndScriptSuccess(lines)
enddef
def Test_assignment_list_any_index()
var l: list<number> = [1, 2]
for [x, y, _]

View File

@@ -3103,6 +3103,7 @@ call_func(
int argv_clear = 0;
int argv_base = 0;
partial_T *partial = funcexe->partial;
type_T check_type;
// Initialize rettv so that it is safe for caller to invoke clear_tv(rettv)
// even when call_func() returns FAIL.
@@ -3146,6 +3147,16 @@ call_func(
argv[i + argv_clear] = argvars_in[i];
argvars = argv;
argcount = partial->pt_argc + argcount_in;
if (funcexe->check_type != NULL)
{
// Now funcexe->check_type is missing the added arguments, make
// a copy of the type with the correction.
check_type = *funcexe->check_type;
funcexe->check_type = &check_type;
check_type.tt_argcount += partial->pt_argc;
check_type.tt_min_argcount += partial->pt_argc;
}
}
}

View File

@@ -755,6 +755,12 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3105,
/**/
3104,
/**/
3103,
/**/
3102,
/**/

View File

@@ -355,7 +355,20 @@ typval2type_int(typval_T *tv, int copyID, garray_T *type_gap, int do_member)
if (ufunc->uf_func_type == NULL)
set_function_type(ufunc);
if (ufunc->uf_func_type != NULL)
{
if (tv->v_type == VAR_PARTIAL
&& tv->vval.v_partial->pt_argc > 0)
{
type = get_type_ptr(type_gap);
if (type == NULL)
return NULL;
*type = *ufunc->uf_func_type;
type->tt_argcount -= tv->vval.v_partial->pt_argc;
type->tt_min_argcount -= tv->vval.v_partial->pt_argc;
return type;
}
return ufunc->uf_func_type;
}
}
}
@@ -526,6 +539,7 @@ check_type(type_T *expected, type_T *actual, int give_msg, where_T where)
ret = check_type(expected->tt_member, actual->tt_member,
FALSE, where);
if (ret == OK && expected->tt_argcount != -1
&& actual->tt_min_argcount != -1
&& (actual->tt_argcount == -1
|| (actual->tt_argcount < expected->tt_min_argcount
|| actual->tt_argcount > expected->tt_argcount)))