mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.2.0339: Vim9: function return type may depend on arguments
Problem: Vim9: function return type may depend on arguments. Solution: Instead of a fixed return type use a function to figure out the return type.
This commit is contained in:
@@ -752,6 +752,12 @@ f_getbufline(typval_T *argvars, typval_T *rettv)
|
|||||||
get_buffer_lines(buf, lnum, end, TRUE, rettv);
|
get_buffer_lines(buf, lnum, end, TRUE, rettv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type_T *
|
||||||
|
ret_f_getline(int argcount, type_T **argtypes UNUSED)
|
||||||
|
{
|
||||||
|
return argcount == 1 ? &t_string : &t_list_string;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "getline(lnum, [end])" function
|
* "getline(lnum, [end])" function
|
||||||
*/
|
*/
|
||||||
|
1084
src/evalfunc.c
1084
src/evalfunc.c
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,7 @@ void f_bufwinnr(typval_T *argvars, typval_T *rettv);
|
|||||||
void f_deletebufline(typval_T *argvars, typval_T *rettv);
|
void f_deletebufline(typval_T *argvars, typval_T *rettv);
|
||||||
void f_getbufinfo(typval_T *argvars, typval_T *rettv);
|
void f_getbufinfo(typval_T *argvars, typval_T *rettv);
|
||||||
void f_getbufline(typval_T *argvars, typval_T *rettv);
|
void f_getbufline(typval_T *argvars, typval_T *rettv);
|
||||||
|
type_T *ret_f_getline(int argcount, type_T **argtypes);
|
||||||
void f_getline(typval_T *argvars, typval_T *rettv);
|
void f_getline(typval_T *argvars, typval_T *rettv);
|
||||||
void f_setbufline(typval_T *argvars, typval_T *rettv);
|
void f_setbufline(typval_T *argvars, typval_T *rettv);
|
||||||
void f_setline(typval_T *argvars, typval_T *rettv);
|
void f_setline(typval_T *argvars, typval_T *rettv);
|
||||||
|
@@ -4,7 +4,7 @@ char_u *get_expr_name(expand_T *xp, int idx);
|
|||||||
int find_internal_func(char_u *name);
|
int find_internal_func(char_u *name);
|
||||||
int has_internal_func(char_u *name);
|
int has_internal_func(char_u *name);
|
||||||
char *internal_func_name(int idx);
|
char *internal_func_name(int idx);
|
||||||
type_T *internal_func_ret_type(int idx, int argcount);
|
type_T *internal_func_ret_type(int idx, int argcount, type_T **argtypes);
|
||||||
int check_internal_func(int idx, int argcount);
|
int check_internal_func(int idx, int argcount);
|
||||||
int call_internal_func(char_u *name, int argcount, typval_T *argvars, typval_T *rettv);
|
int call_internal_func(char_u *name, int argcount, typval_T *argvars, typval_T *rettv);
|
||||||
void call_internal_func_by_idx(int idx, typval_T *argvars, typval_T *rettv);
|
void call_internal_func_by_idx(int idx, typval_T *argvars, typval_T *rettv);
|
||||||
|
@@ -55,7 +55,12 @@ def Test_assignment()
|
|||||||
|
|
||||||
if has('channel')
|
if has('channel')
|
||||||
let chan1: channel
|
let chan1: channel
|
||||||
|
let job1: job
|
||||||
endif
|
endif
|
||||||
|
if has('float')
|
||||||
|
let float1: float = 3.4
|
||||||
|
endif
|
||||||
|
let party: partial = funcref('Test_syntax')
|
||||||
|
|
||||||
g:newvar = 'new'
|
g:newvar = 'new'
|
||||||
assert_equal('new', g:newvar)
|
assert_equal('new', g:newvar)
|
||||||
|
@@ -738,6 +738,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 */
|
||||||
|
/**/
|
||||||
|
339,
|
||||||
/**/
|
/**/
|
||||||
338,
|
338,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -992,6 +992,8 @@ generate_BCALL(cctx_T *cctx, int func_idx, int argcount)
|
|||||||
{
|
{
|
||||||
isn_T *isn;
|
isn_T *isn;
|
||||||
garray_T *stack = &cctx->ctx_type_stack;
|
garray_T *stack = &cctx->ctx_type_stack;
|
||||||
|
type_T *argtypes[MAX_FUNC_ARGS];
|
||||||
|
int i;
|
||||||
|
|
||||||
if (check_internal_func(func_idx, argcount) == FAIL)
|
if (check_internal_func(func_idx, argcount) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -1001,11 +1003,14 @@ generate_BCALL(cctx_T *cctx, int func_idx, int argcount)
|
|||||||
isn->isn_arg.bfunc.cbf_idx = func_idx;
|
isn->isn_arg.bfunc.cbf_idx = func_idx;
|
||||||
isn->isn_arg.bfunc.cbf_argcount = argcount;
|
isn->isn_arg.bfunc.cbf_argcount = argcount;
|
||||||
|
|
||||||
|
for (i = 0; i < argcount; ++i)
|
||||||
|
argtypes[i] = ((type_T **)stack->ga_data)[stack->ga_len - argcount + i];
|
||||||
|
|
||||||
stack->ga_len -= argcount; // drop the arguments
|
stack->ga_len -= argcount; // drop the arguments
|
||||||
if (ga_grow(stack, 1) == FAIL)
|
if (ga_grow(stack, 1) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
((type_T **)stack->ga_data)[stack->ga_len] =
|
((type_T **)stack->ga_data)[stack->ga_len] =
|
||||||
internal_func_ret_type(func_idx, argcount);
|
internal_func_ret_type(func_idx, argcount, argtypes);
|
||||||
++stack->ga_len; // add return value
|
++stack->ga_len; // add return value
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -1374,7 +1379,7 @@ parse_type(char_u **arg, garray_T *type_list)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
if (len == 4 && STRNCMP(*arg, "partial", len) == 0)
|
if (len == 7 && STRNCMP(*arg, "partial", len) == 0)
|
||||||
{
|
{
|
||||||
*arg += len;
|
*arg += len;
|
||||||
// TODO: arguments and return type
|
// TODO: arguments and return type
|
||||||
|
Reference in New Issue
Block a user