@@ -5272,16 +5272,21 @@ call_def_function(
52725272 ufunc_T * ufunc ,
52735273 int argc_arg , // nr of arguments
52745274 typval_T * argv , // arguments
5275+ int flags , // DEF_ flags
52755276 partial_T * partial , // optional partial for context
52765277 funccall_T * funccal ,
52775278 typval_T * rettv ) // return value
52785279{
52795280 ectx_T ectx ; // execution context
52805281 int argc = argc_arg ;
5282+ int partial_argc = partial == NULL
5283+ || (flags & DEF_USE_PT_ARGV ) == 0
5284+ ? 0 : partial -> pt_argc ;
5285+ int total_argc = argc + partial_argc ;
52815286 typval_T * tv ;
52825287 int idx ;
52835288 int ret = FAIL ;
5284- int defcount = ufunc -> uf_args .ga_len - argc ;
5289+ int defcount = ufunc -> uf_args .ga_len - total_argc ;
52855290 sctx_T save_current_sctx = current_sctx ;
52865291 int did_emsg_before = did_emsg_cumul + did_emsg ;
52875292 int save_suppress_errthrow = suppress_errthrow ;
@@ -5345,30 +5350,34 @@ call_def_function(
53455350 ectx .ec_did_emsg_before = did_emsg_before ;
53465351 ++ ex_nesting_level ;
53475352
5348- idx = argc - ufunc -> uf_args .ga_len ;
5353+ idx = total_argc - ufunc -> uf_args .ga_len ;
53495354 if (idx > 0 && ufunc -> uf_va_name == NULL )
53505355 {
53515356 semsg (NGETTEXT (e_one_argument_too_many , e_nr_arguments_too_many ,
5352- idx ), idx );
5357+ idx ), idx );
53535358 goto failed_early ;
53545359 }
5355- idx = argc - ufunc -> uf_args .ga_len + ufunc -> uf_def_args .ga_len ;
5360+ idx = total_argc - ufunc -> uf_args .ga_len + ufunc -> uf_def_args .ga_len ;
53565361 if (idx < 0 )
53575362 {
53585363 semsg (NGETTEXT (e_one_argument_too_few , e_nr_arguments_too_few ,
53595364 - idx ), - idx );
53605365 goto failed_early ;
53615366 }
53625367
5363- // Put arguments on the stack, but no more than what the function expects.
5364- // A lambda can be called with more arguments than it uses.
5365- for (idx = 0 ; idx < argc
5368+ // Put values from the partial and arguments on the stack, but no more than
5369+ // what the function expects. A lambda can be called with more arguments
5370+ // than it uses.
5371+ for (idx = 0 ; idx < total_argc
53665372 && (ufunc -> uf_va_name != NULL || idx < ufunc -> uf_args .ga_len );
53675373 ++ idx )
53685374 {
5375+ int argv_idx = idx - partial_argc ;
5376+
5377+ tv = idx < partial_argc ? partial -> pt_argv + idx : argv + argv_idx ;
53695378 if (idx >= ufunc -> uf_args .ga_len - ufunc -> uf_def_args .ga_len
5370- && argv [ idx ]. v_type == VAR_SPECIAL
5371- && argv [ idx ]. vval .v_number == VVAL_NONE )
5379+ && tv -> v_type == VAR_SPECIAL
5380+ && tv -> vval .v_number == VVAL_NONE )
53725381 {
53735382 // Use the default value.
53745383 STACK_TV_BOT (0 )-> v_type = VAR_UNKNOWN ;
@@ -5377,10 +5386,10 @@ call_def_function(
53775386 {
53785387 if (ufunc -> uf_arg_types != NULL && idx < ufunc -> uf_args .ga_len
53795388 && check_typval_arg_type (
5380- ufunc -> uf_arg_types [idx ], & argv [ idx ] ,
5381- NULL , idx + 1 ) == FAIL )
5389+ ufunc -> uf_arg_types [idx ], tv ,
5390+ NULL , argv_idx + 1 ) == FAIL )
53825391 goto failed_early ;
5383- copy_tv (& argv [ idx ] , STACK_TV_BOT (0 ));
5392+ copy_tv (tv , STACK_TV_BOT (0 ));
53845393 }
53855394 ++ ectx .ec_stack .ga_len ;
53865395 }
0 commit comments