Mercurial > vim
comparison src/userfunc.c @ 25137:34f18d4081af v8.2.3105
patch 8.2.3105: Vim9: type of partial is wrong when it has arguments
Commit: https://github.com/vim/vim/commit/97f227d9c9351f12138d923ffdf9232dc5520bef
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 4 20:20:52 2021 +0200
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 https://github.com/vim/vim/issues/8492)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 04 Jul 2021 20:30:03 +0200 |
parents | 80cab530472b |
children | 99f6087a5fd2 |
comparison
equal
deleted
inserted
replaced
25136:d838f9187c57 | 25137:34f18d4081af |
---|---|
3101 typval_T argv[MAX_FUNC_ARGS + 1]; // used when "partial" or | 3101 typval_T argv[MAX_FUNC_ARGS + 1]; // used when "partial" or |
3102 // "funcexe->basetv" is not NULL | 3102 // "funcexe->basetv" is not NULL |
3103 int argv_clear = 0; | 3103 int argv_clear = 0; |
3104 int argv_base = 0; | 3104 int argv_base = 0; |
3105 partial_T *partial = funcexe->partial; | 3105 partial_T *partial = funcexe->partial; |
3106 type_T check_type; | |
3106 | 3107 |
3107 // Initialize rettv so that it is safe for caller to invoke clear_tv(rettv) | 3108 // Initialize rettv so that it is safe for caller to invoke clear_tv(rettv) |
3108 // even when call_func() returns FAIL. | 3109 // even when call_func() returns FAIL. |
3109 rettv->v_type = VAR_UNKNOWN; | 3110 rettv->v_type = VAR_UNKNOWN; |
3110 | 3111 |
3144 } | 3145 } |
3145 for (i = 0; i < argcount_in; ++i) | 3146 for (i = 0; i < argcount_in; ++i) |
3146 argv[i + argv_clear] = argvars_in[i]; | 3147 argv[i + argv_clear] = argvars_in[i]; |
3147 argvars = argv; | 3148 argvars = argv; |
3148 argcount = partial->pt_argc + argcount_in; | 3149 argcount = partial->pt_argc + argcount_in; |
3150 | |
3151 if (funcexe->check_type != NULL) | |
3152 { | |
3153 // Now funcexe->check_type is missing the added arguments, make | |
3154 // a copy of the type with the correction. | |
3155 check_type = *funcexe->check_type; | |
3156 funcexe->check_type = &check_type; | |
3157 check_type.tt_argcount += partial->pt_argc; | |
3158 check_type.tt_min_argcount += partial->pt_argc; | |
3159 } | |
3149 } | 3160 } |
3150 } | 3161 } |
3151 | 3162 |
3152 if (error == FCERR_NONE && funcexe->check_type != NULL && funcexe->evaluate) | 3163 if (error == FCERR_NONE && funcexe->check_type != NULL && funcexe->evaluate) |
3153 { | 3164 { |