comparison src/vim9compile.c @ 21789:f84625b961a8 v8.2.1444

patch 8.2.1444: error messages are spread out and names can be confusing Commit: https://github.com/vim/vim/commit/bc4c505166dc82911553206bb0c2133c6ac94aa1 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 13 22:47:35 2020 +0200 patch 8.2.1444: error messages are spread out and names can be confusing Problem: Error messages are spread out and names can be confusing. Solution: Start moving error messages to a separate file and use clear names.
author Bram Moolenaar <Bram@vim.org>
date Thu, 13 Aug 2020 23:00:04 +0200
parents fcf978444298
children fdd58acef1cc
comparison
equal deleted inserted replaced
21788:acd6c7f8b633 21789:f84625b961a8
300 || lookup_arg(p, len, NULL, NULL, NULL, cctx) == OK)) 300 || lookup_arg(p, len, NULL, NULL, NULL, cctx) == OK))
301 || find_imported(p, len, cctx) != NULL 301 || find_imported(p, len, cctx) != NULL
302 || find_func_even_dead(p, FALSE, cctx) != NULL) 302 || find_func_even_dead(p, FALSE, cctx) != NULL)
303 { 303 {
304 p[len] = c; 304 p[len] = c;
305 semsg(_(e_already_defined), p); 305 semsg(_(e_name_already_defined), p);
306 return FAIL; 306 return FAIL;
307 } 307 }
308 p[len] = c; 308 p[len] = c;
309 return OK; 309 return OK;
310 } 310 }
2204 return FAIL; 2204 return FAIL;
2205 ++*argcount; 2205 ++*argcount;
2206 2206
2207 if (*p != ',' && *skipwhite(p) == ',') 2207 if (*p != ',' && *skipwhite(p) == ',')
2208 { 2208 {
2209 semsg(_(e_no_white_before), ","); 2209 semsg(_(e_no_white_space_allowed_before), ",");
2210 p = skipwhite(p); 2210 p = skipwhite(p);
2211 } 2211 }
2212 if (*p == ',') 2212 if (*p == ',')
2213 { 2213 {
2214 ++p; 2214 ++p;
2215 if (*p != NUL && !VIM_ISWHITE(*p)) 2215 if (*p != NUL && !VIM_ISWHITE(*p))
2216 semsg(_(e_white_after), ","); 2216 semsg(_(e_white_space_required_after), ",");
2217 } 2217 }
2218 whitep = p; 2218 whitep = p;
2219 p = skipwhite(p); 2219 p = skipwhite(p);
2220 } 2220 }
2221 failret: 2221 failret:
2429 semsg(_(e_list_end), *arg); 2429 semsg(_(e_list_end), *arg);
2430 return FAIL; 2430 return FAIL;
2431 } 2431 }
2432 if (*p == ',') 2432 if (*p == ',')
2433 { 2433 {
2434 semsg(_(e_no_white_before), ","); 2434 semsg(_(e_no_white_space_allowed_before), ",");
2435 return FAIL; 2435 return FAIL;
2436 } 2436 }
2437 if (*p == ']') 2437 if (*p == ']')
2438 { 2438 {
2439 ++p; 2439 ++p;
2448 if (*p == ',') 2448 if (*p == ',')
2449 { 2449 {
2450 ++p; 2450 ++p;
2451 if (*p != ']' && !IS_WHITE_OR_NUL(*p)) 2451 if (*p != ']' && !IS_WHITE_OR_NUL(*p))
2452 { 2452 {
2453 semsg(_(e_white_after), ","); 2453 semsg(_(e_white_space_required_after), ",");
2454 return FAIL; 2454 return FAIL;
2455 } 2455 }
2456 } 2456 }
2457 whitep = p; 2457 whitep = p;
2458 p = skipwhite(p); 2458 p = skipwhite(p);
2634 } 2634 }
2635 2635
2636 if (**arg != ':') 2636 if (**arg != ':')
2637 { 2637 {
2638 if (*skipwhite(*arg) == ':') 2638 if (*skipwhite(*arg) == ':')
2639 semsg(_(e_no_white_before), ":"); 2639 semsg(_(e_no_white_space_allowed_before), ":");
2640 else 2640 else
2641 semsg(_(e_missing_dict_colon), *arg); 2641 semsg(_(e_missing_dict_colon), *arg);
2642 return FAIL; 2642 return FAIL;
2643 } 2643 }
2644 whitep = *arg + 1; 2644 whitep = *arg + 1;
2645 if (!IS_WHITE_OR_NUL(*whitep)) 2645 if (!IS_WHITE_OR_NUL(*whitep))
2646 { 2646 {
2647 semsg(_(e_white_after), ":"); 2647 semsg(_(e_white_space_required_after), ":");
2648 return FAIL; 2648 return FAIL;
2649 } 2649 }
2650 2650
2651 *arg = skipwhite(*arg + 1); 2651 *arg = skipwhite(*arg + 1);
2652 if (may_get_next_line(whitep, arg, cctx) == FAIL) 2652 if (may_get_next_line(whitep, arg, cctx) == FAIL)
2673 semsg(_(e_missing_dict_comma), *arg); 2673 semsg(_(e_missing_dict_comma), *arg);
2674 goto failret; 2674 goto failret;
2675 } 2675 }
2676 if (IS_WHITE_OR_NUL(*whitep)) 2676 if (IS_WHITE_OR_NUL(*whitep))
2677 { 2677 {
2678 semsg(_(e_no_white_before), ","); 2678 semsg(_(e_no_white_space_allowed_before), ",");
2679 return FAIL; 2679 return FAIL;
2680 } 2680 }
2681 whitep = *arg + 1; 2681 whitep = *arg + 1;
2682 *arg = skipwhite(*arg + 1); 2682 *arg = skipwhite(*arg + 1);
2683 } 2683 }
3150 if (generate_instr_drop(cctx, ISN_LISTINDEX, 1) == FAIL) 3150 if (generate_instr_drop(cctx, ISN_LISTINDEX, 1) == FAIL)
3151 return FAIL; 3151 return FAIL;
3152 } 3152 }
3153 else 3153 else
3154 { 3154 {
3155 emsg(_(e_listdictblobreq)); 3155 emsg(_(e_list_dict_or_blob_required));
3156 return FAIL; 3156 return FAIL;
3157 } 3157 }
3158 } 3158 }
3159 else if (*p == '.' && p[1] != '.') 3159 else if (*p == '.' && p[1] != '.')
3160 { 3160 {
3467 error_white_both(char_u *op, int len) 3467 error_white_both(char_u *op, int len)
3468 { 3468 {
3469 char_u buf[10]; 3469 char_u buf[10];
3470 3470
3471 vim_strncpy(buf, op, len); 3471 vim_strncpy(buf, op, len);
3472 semsg(_(e_white_both), buf); 3472 semsg(_(e_white_space_required_before_and_after), buf);
3473 } 3473 }
3474 3474
3475 /* 3475 /*
3476 * <type>expr7: runtime type check / conversion 3476 * <type>expr7: runtime type check / conversion
3477 */ 3477 */
3491 return FAIL; 3491 return FAIL;
3492 3492
3493 if (**arg != '>') 3493 if (**arg != '>')
3494 { 3494 {
3495 if (*skipwhite(*arg) == '>') 3495 if (*skipwhite(*arg) == '>')
3496 semsg(_(e_no_white_before), ">"); 3496 semsg(_(e_no_white_space_allowed_before), ">");
3497 else 3497 else
3498 emsg(_("E1104: Missing >")); 3498 emsg(_("E1104: Missing >"));
3499 return FAIL; 3499 return FAIL;
3500 } 3500 }
3501 ++*arg; 3501 ++*arg;
3835 p = skipwhite(*arg); 3835 p = skipwhite(*arg);
3836 } 3836 }
3837 3837
3838 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[2])) 3838 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[2]))
3839 { 3839 {
3840 semsg(_(e_white_both), op); 3840 semsg(_(e_white_space_required_before_and_after), op);
3841 return FAIL; 3841 return FAIL;
3842 } 3842 }
3843 3843
3844 // TODO: use ppconst if the value is a constant 3844 // TODO: use ppconst if the value is a constant
3845 generate_ppconst(cctx, ppconst); 3845 generate_ppconst(cctx, ppconst);
3976 p = skipwhite(*arg); 3976 p = skipwhite(*arg);
3977 } 3977 }
3978 3978
3979 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1])) 3979 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1]))
3980 { 3980 {
3981 semsg(_(e_white_both), "?"); 3981 semsg(_(e_white_space_required_before_and_after), "?");
3982 return FAIL; 3982 return FAIL;
3983 } 3983 }
3984 3984
3985 if (ppconst->pp_used == ppconst_used + 1) 3985 if (ppconst->pp_used == ppconst_used + 1)
3986 { 3986 {
4035 p = skipwhite(*arg); 4035 p = skipwhite(*arg);
4036 } 4036 }
4037 4037
4038 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1])) 4038 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1]))
4039 { 4039 {
4040 semsg(_(e_white_both), ":"); 4040 semsg(_(e_white_space_required_before_and_after), ":");
4041 return FAIL; 4041 return FAIL;
4042 } 4042 }
4043 4043
4044 // evaluate the third expression 4044 // evaluate the third expression
4045 if (has_const_expr) 4045 if (has_const_expr)
4335 case 'g': scope = _("global"); break; 4335 case 'g': scope = _("global"); break;
4336 case 'b': scope = _("buffer"); break; 4336 case 'b': scope = _("buffer"); break;
4337 case 'w': scope = _("window"); break; 4337 case 'w': scope = _("window"); break;
4338 case 't': scope = _("tab"); break; 4338 case 't': scope = _("tab"); break;
4339 case 'v': scope = "v:"; break; 4339 case 'v': scope = "v:"; break;
4340 case '$': semsg(_(e_declare_env_var), name); 4340 case '$': semsg(_(e_cannot_declare_an_environment_variable), name);
4341 return; 4341 return;
4342 case '&': semsg(_("E1052: Cannot declare an option: %s"), name); 4342 case '&': semsg(_("E1052: Cannot declare an option: %s"), name);
4343 return; 4343 return;
4344 case '@': semsg(_("E1066: Cannot declare a register: %s"), name); 4344 case '@': semsg(_("E1066: Cannot declare a register: %s"), name);
4345 return; 4345 return;
4346 default: return; 4346 default: return;
4347 } 4347 }
4348 semsg(_(e_declare_var), scope, name); 4348 semsg(_(e_cannot_declare_a_scope_variable), scope, name);
4349 } 4349 }
4350 4350
4351 /* 4351 /*
4352 * Compile declaration and assignment: 4352 * Compile declaration and assignment:
4353 * "let var", "let var = expr", "const var = expr" and "var = expr" 4353 * "let var", "let var = expr", "const var = expr" and "var = expr"
4722 if (is_decl && *p == ':') 4722 if (is_decl && *p == ':')
4723 { 4723 {
4724 // parse optional type: "let var: type = expr" 4724 // parse optional type: "let var: type = expr"
4725 if (!VIM_ISWHITE(p[1])) 4725 if (!VIM_ISWHITE(p[1]))
4726 { 4726 {
4727 semsg(_(e_white_after), ":"); 4727 semsg(_(e_white_space_required_after), ":");
4728 goto theend; 4728 goto theend;
4729 } 4729 }
4730 p = skipwhite(p + 1); 4730 p = skipwhite(p + 1);
4731 type = parse_type(&p, cctx->ctx_type_list); 4731 type = parse_type(&p, cctx->ctx_type_list);
4732 has_type = TRUE; 4732 has_type = TRUE;
4901 cctx, FALSE) == FAIL) 4901 cctx, FALSE) == FAIL)
4902 goto theend; 4902 goto theend;
4903 } 4903 }
4904 else if (cmdidx == CMD_const) 4904 else if (cmdidx == CMD_const)
4905 { 4905 {
4906 emsg(_(e_const_req_value)); 4906 emsg(_(e_const_requires_a_value));
4907 goto theend; 4907 goto theend;
4908 } 4908 }
4909 else if (!has_type || dest == dest_option) 4909 else if (!has_type || dest == dest_option)
4910 { 4910 {
4911 emsg(_(e_type_req)); 4911 emsg(_(e_type_or_initialization_required));
4912 goto theend; 4912 goto theend;
4913 } 4913 }
4914 else 4914 else
4915 { 4915 {
4916 // variables are always initialized 4916 // variables are always initialized
6622 if (*cmd != '\'' || starts_with_colon) 6622 if (*cmd != '\'' || starts_with_colon)
6623 { 6623 {
6624 ea.cmd = skip_range(ea.cmd, NULL); 6624 ea.cmd = skip_range(ea.cmd, NULL);
6625 if (ea.cmd > cmd && !starts_with_colon) 6625 if (ea.cmd > cmd && !starts_with_colon)
6626 { 6626 {
6627 emsg(_(e_colon_required)); 6627 emsg(_(e_colon_required_before_a_range));
6628 goto erret; 6628 goto erret;
6629 } 6629 }
6630 } 6630 }
6631 p = find_ex_command(&ea, NULL, starts_with_colon ? NULL 6631 p = find_ex_command(&ea, NULL, starts_with_colon ? NULL
6632 : (void *(*)(char_u *, size_t, cctx_T *))lookup_local, 6632 : (void *(*)(char_u *, size_t, cctx_T *))lookup_local,