comparison src/vim9execute.c @ 28263:c446812efd60 v8.2.4657

patch 8.2.4657: errors for functions are sometimes hard to read Commit: https://github.com/vim/vim/commit/a6c18d38ca2df0a92403f2265a480d9dba08290f Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 31 20:02:56 2022 +0100 patch 8.2.4657: errors for functions are sometimes hard to read Problem: Errors for functions are sometimes hard to read. Solution: Use printable_func_name() in more places.
author Bram Moolenaar <Bram@vim.org>
date Thu, 31 Mar 2022 21:15:03 +0200
parents d817abf991df
children fff70771d4bb
comparison
equal deleted inserted replaced
28262:59a7125e87f4 28263:c446812efd60
1010 { 1010 {
1011 error = check_user_func_argcount(ufunc, argcount); 1011 error = check_user_func_argcount(ufunc, argcount);
1012 if (error != FCERR_UNKNOWN) 1012 if (error != FCERR_UNKNOWN)
1013 { 1013 {
1014 if (error == FCERR_TOOMANY) 1014 if (error == FCERR_TOOMANY)
1015 semsg(_(e_too_many_arguments_for_function_str), ufunc->uf_name); 1015 semsg(_(e_too_many_arguments_for_function_str),
1016 printable_func_name(ufunc));
1016 else 1017 else
1017 semsg(_(e_not_enough_arguments_for_function_str), 1018 semsg(_(e_not_enough_arguments_for_function_str),
1018 ufunc->uf_name); 1019 printable_func_name(ufunc));
1019 return FAIL; 1020 return FAIL;
1020 } 1021 }
1021 1022
1022 // The function has been compiled, can call it quickly. For a function 1023 // The function has been compiled, can call it quickly. For a function
1023 // that was defined later: we can call it directly next time. 1024 // that was defined later: we can call it directly next time.
1045 for (idx = 0; idx < argcount; ++idx) 1046 for (idx = 0; idx < argcount; ++idx)
1046 clear_tv(&argvars[idx]); 1047 clear_tv(&argvars[idx]);
1047 1048
1048 if (error != FCERR_NONE) 1049 if (error != FCERR_NONE)
1049 { 1050 {
1050 user_func_error(error, ufunc->uf_name, &funcexe); 1051 user_func_error(error, printable_func_name(ufunc), &funcexe);
1051 return FAIL; 1052 return FAIL;
1052 } 1053 }
1053 if (did_emsg > did_emsg_before) 1054 if (did_emsg > did_emsg_before)
1054 // Error other than from calling the function itself. 1055 // Error other than from calling the function itself.
1055 return FAIL; 1056 return FAIL;
1209 } 1210 }
1210 1211
1211 if (res == FAIL) 1212 if (res == FAIL)
1212 { 1213 {
1213 if (called_emsg == called_emsg_before) 1214 if (called_emsg == called_emsg_before)
1214 semsg(_(e_unknown_function_str), 1215 emsg_funcname(e_unknown_function_str,
1215 name == NULL ? (char_u *)"[unknown]" : name); 1216 name == NULL ? (char_u *)"[unknown]" : name);
1216 return FAIL; 1217 return FAIL;
1217 } 1218 }
1218 return OK; 1219 return OK;
1219 } 1220 }
1568 if (res == FAIL && called_emsg == called_emsg_before) 1569 if (res == FAIL && called_emsg == called_emsg_before)
1569 { 1570 {
1570 dictitem_T *v; 1571 dictitem_T *v;
1571 1572
1572 v = find_var(name, NULL, FALSE); 1573 v = find_var(name, NULL, FALSE);
1573 if (v == NULL) 1574 if (v == NULL || (v->di_tv.v_type != VAR_PARTIAL
1575 && v->di_tv.v_type != VAR_FUNC))
1574 { 1576 {
1575 semsg(_(e_unknown_function_str), name); 1577 emsg_funcname(e_unknown_function_str, name);
1576 return FAIL;
1577 }
1578 if (v->di_tv.v_type != VAR_PARTIAL && v->di_tv.v_type != VAR_FUNC)
1579 {
1580 semsg(_(e_unknown_function_str), name);
1581 return FAIL; 1578 return FAIL;
1582 } 1579 }
1583 return call_partial(&v->di_tv, argcount, ectx); 1580 return call_partial(&v->di_tv, argcount, ectx);
1584 } 1581 }
1585 return res; 1582 return res;