Mercurial > vim
comparison src/evalfunc.c @ 25465:b8a6a0007dc3 v8.2.3269
patch 8.2.3269: Vim9: wrong argument check for partial
Commit: https://github.com/vim/vim/commit/f78da4f9d6daf1907e4ce4be74146375dbd9a546
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 1 15:40:31 2021 +0200
patch 8.2.3269: Vim9: wrong argument check for partial
Problem: Vim9: wrong argument check for partial. (Naohiro Ono)
Solution: Handle getting return type without arguments. Correct the minimal
number of arguments for what is included in the partial.
(closes #8667)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Aug 2021 15:45:04 +0200 |
parents | 5dce28f92d04 |
children | fbdfa533001c |
comparison
equal
deleted
inserted
replaced
25464:f0546dfb74e2 | 25465:b8a6a0007dc3 |
---|---|
930 if (argcount > 0) | 930 if (argcount > 0) |
931 return argtypes[0]; | 931 return argtypes[0]; |
932 return &t_void; | 932 return &t_void; |
933 } | 933 } |
934 static type_T * | 934 static type_T * |
935 ret_repeat(int argcount UNUSED, type_T **argtypes) | 935 ret_repeat(int argcount, type_T **argtypes) |
936 { | 936 { |
937 if (argcount == 0) | |
938 return &t_any; | |
937 if (argtypes[0] == &t_number) | 939 if (argtypes[0] == &t_number) |
938 return &t_string; | 940 return &t_string; |
939 return argtypes[0]; | 941 return argtypes[0]; |
940 } | 942 } |
941 // for map(): returns first argument but item type may differ | 943 // for map(): returns first argument but item type may differ |
942 static type_T * | 944 static type_T * |
943 ret_first_cont(int argcount UNUSED, type_T **argtypes) | 945 ret_first_cont(int argcount, type_T **argtypes) |
944 { | 946 { |
945 if (argtypes[0]->tt_type == VAR_LIST) | 947 if (argcount > 0) |
946 return &t_list_any; | 948 { |
947 if (argtypes[0]->tt_type == VAR_DICT) | 949 if (argtypes[0]->tt_type == VAR_LIST) |
948 return &t_dict_any; | 950 return &t_list_any; |
949 if (argtypes[0]->tt_type == VAR_BLOB) | 951 if (argtypes[0]->tt_type == VAR_DICT) |
950 return argtypes[0]; | 952 return &t_dict_any; |
953 if (argtypes[0]->tt_type == VAR_BLOB) | |
954 return argtypes[0]; | |
955 } | |
951 return &t_any; | 956 return &t_any; |
952 } | 957 } |
953 | 958 |
954 /* | 959 /* |
955 * Used for getqflist(): returns list if there is no argument, dict if there is | 960 * Used for getqflist(): returns list if there is no argument, dict if there is |
985 // argv(0) returns a string, but argv(-1] returns a list | 990 // argv(0) returns a string, but argv(-1] returns a list |
986 return &t_any; | 991 return &t_any; |
987 } | 992 } |
988 | 993 |
989 static type_T * | 994 static type_T * |
990 ret_remove(int argcount UNUSED, type_T **argtypes) | 995 ret_remove(int argcount, type_T **argtypes) |
991 { | 996 { |
992 if (argtypes != NULL) | 997 if (argcount > 0) |
993 { | 998 { |
994 if (argtypes[0]->tt_type == VAR_LIST | 999 if (argtypes[0]->tt_type == VAR_LIST |
995 || argtypes[0]->tt_type == VAR_DICT) | 1000 || argtypes[0]->tt_type == VAR_DICT) |
996 return argtypes[0]->tt_member; | 1001 return argtypes[0]->tt_member; |
997 if (argtypes[0]->tt_type == VAR_BLOB) | 1002 if (argtypes[0]->tt_type == VAR_BLOB) |
2444 | 2449 |
2445 /* | 2450 /* |
2446 * Call the "f_retfunc" function to obtain the return type of function "idx". | 2451 * Call the "f_retfunc" function to obtain the return type of function "idx". |
2447 * "argtypes" is the list of argument types or NULL when there are no | 2452 * "argtypes" is the list of argument types or NULL when there are no |
2448 * arguments. | 2453 * arguments. |
2454 * "argcount" may be less than the actual count when only getting the type. | |
2449 */ | 2455 */ |
2450 type_T * | 2456 type_T * |
2451 internal_func_ret_type(int idx, int argcount, type_T **argtypes) | 2457 internal_func_ret_type(int idx, int argcount, type_T **argtypes) |
2452 { | 2458 { |
2453 return global_functions[idx].f_retfunc(argcount, argtypes); | 2459 return global_functions[idx].f_retfunc(argcount, argtypes); |