comparison src/vim9type.c @ 26833:434eaef2ac62 v8.2.3945

patch 8.2.3945: Vim9: partial variable argument types are wrong Commit: https://github.com/vim/vim/commit/13789bf10338a0d049c78acfdc0870fc63e63f4f Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 30 13:29:00 2021 +0000 patch 8.2.3945: Vim9: partial variable argument types are wrong Problem: Vim9: partial variable argument types are wrong, leading to a crash. Solution: When adjusting the argument count also adjust the argument types. (closes #9433)
author Bram Moolenaar <Bram@vim.org>
date Thu, 30 Dec 2021 14:30:04 +0100
parents 1b288eb2fcdc
children eb6d56ab4858
comparison
equal deleted inserted replaced
26832:eb188d6e2e41 26833:434eaef2ac62
369 if (type == NULL) 369 if (type == NULL)
370 return NULL; 370 return NULL;
371 *type = *ufunc->uf_func_type; 371 *type = *ufunc->uf_func_type;
372 type->tt_argcount -= tv->vval.v_partial->pt_argc; 372 type->tt_argcount -= tv->vval.v_partial->pt_argc;
373 type->tt_min_argcount -= tv->vval.v_partial->pt_argc; 373 type->tt_min_argcount -= tv->vval.v_partial->pt_argc;
374 if (type->tt_argcount == 0)
375 type->tt_args = NULL;
376 else
377 {
378 int i;
379
380 func_type_add_arg_types(type, type->tt_argcount,
381 type_gap);
382 for (i = 0; i < type->tt_argcount; ++i)
383 type->tt_args[i] = ufunc->uf_func_type->tt_args[
384 i + tv->vval.v_partial->pt_argc];
385 }
374 return type; 386 return type;
375 } 387 }
376 return ufunc->uf_func_type; 388 return ufunc->uf_func_type;
377 } 389 }
378 } 390 }
461 check_typval_type(type_T *expected, typval_T *actual_tv, where_T where) 473 check_typval_type(type_T *expected, typval_T *actual_tv, where_T where)
462 { 474 {
463 garray_T type_list; 475 garray_T type_list;
464 type_T *actual_type; 476 type_T *actual_type;
465 int res = FAIL; 477 int res = FAIL;
478
479 if (expected == NULL)
480 return OK; // didn't expect anything.
466 481
467 // For some values there is no type, assume an error will be given later 482 // For some values there is no type, assume an error will be given later
468 // for an invalid value. 483 // for an invalid value.
469 if ((actual_tv->v_type == VAR_FUNC && actual_tv->vval.v_string == NULL) 484 if ((actual_tv->v_type == VAR_FUNC && actual_tv->vval.v_string == NULL)
470 || (actual_tv->v_type == VAR_PARTIAL 485 || (actual_tv->v_type == VAR_PARTIAL