mirror of
https://github.com/vim/vim.git
synced 2025-11-13 22:54:27 -05:00
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Problem: Vim9: it is not possible to extend a dictionary with different
item types.
Solution: Add extendnew(). (closes #7666)
This commit is contained in:
@@ -340,7 +340,7 @@ arg_list_or_dict(type_T *type, argcontext_T *context)
|
||||
}
|
||||
|
||||
/*
|
||||
* Check "type" is the same type as the previous argument
|
||||
* Check "type" is the same type as the previous argument.
|
||||
* Must not be used for the first argcheck_T entry.
|
||||
*/
|
||||
static int
|
||||
@@ -351,6 +351,21 @@ arg_same_as_prev(type_T *type, argcontext_T *context)
|
||||
return check_arg_type(prev_type, type, context->arg_idx + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check "type" is the same basic type as the previous argument, checks list or
|
||||
* dict vs other type, but not member type.
|
||||
* Must not be used for the first argcheck_T entry.
|
||||
*/
|
||||
static int
|
||||
arg_same_struct_as_prev(type_T *type, argcontext_T *context)
|
||||
{
|
||||
type_T *prev_type = context->arg_types[context->arg_idx - 1];
|
||||
|
||||
if (prev_type->tt_type != context->arg_types[context->arg_idx]->tt_type)
|
||||
return check_arg_type(prev_type, type, context->arg_idx + 1);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check "type" is an item of the list or blob of the previous arg.
|
||||
* Must not be used for the first argcheck_T entry.
|
||||
@@ -394,6 +409,7 @@ arg_extend3(type_T *type, argcontext_T *context)
|
||||
argcheck_T arg1_float_or_nr[] = {arg_float_or_nr};
|
||||
argcheck_T arg2_listblob_item[] = {arg_list_or_blob, arg_item_of_prev};
|
||||
argcheck_T arg23_extend[] = {arg_list_or_dict, arg_same_as_prev, arg_extend3};
|
||||
argcheck_T arg23_extendnew[] = {arg_list_or_dict, arg_same_struct_as_prev, arg_extend3};
|
||||
argcheck_T arg3_insert[] = {arg_list_or_blob, arg_item_of_prev, arg_number};
|
||||
|
||||
/*
|
||||
@@ -877,6 +893,8 @@ static funcentry_T global_functions[] =
|
||||
ret_string, f_expandcmd},
|
||||
{"extend", 2, 3, FEARG_1, arg23_extend,
|
||||
ret_first_arg, f_extend},
|
||||
{"extendnew", 2, 3, FEARG_1, arg23_extendnew,
|
||||
ret_first_cont, f_extendnew},
|
||||
{"feedkeys", 1, 2, FEARG_1, NULL,
|
||||
ret_void, f_feedkeys},
|
||||
{"file_readable", 1, 1, FEARG_1, NULL, // obsolete
|
||||
|
||||
Reference in New Issue
Block a user