comparison src/vim9compile.c @ 23446:b1dbbc81a011 v8.2.2266

patch 8.2.2266: Vim9: it can be hard to see where white space is missing Commit: https://github.com/vim/vim/commit/e7a73e07625b64a40671a0007ad38a34cbe9d1ee Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 1 19:17:55 2021 +0100 patch 8.2.2266: Vim9: it can be hard to see where white space is missing Problem: Vim9: it can be hard to see where white space is missing. Solution: Mention the text where the error was seen. (closes https://github.com/vim/vim/issues/7580)
author Bram Moolenaar <Bram@vim.org>
date Fri, 01 Jan 2021 19:30:04 +0100
parents b0587f7ec422
children a8e7acf71fa4
comparison
equal deleted inserted replaced
23445:311caf397f9b 23446:b1dbbc81a011
3654 { 3654 {
3655 if (compile_expr0(arg, cctx) == FAIL) 3655 if (compile_expr0(arg, cctx) == FAIL)
3656 return FAIL; 3656 return FAIL;
3657 if (**arg == ':') 3657 if (**arg == ':')
3658 { 3658 {
3659 semsg(_(e_white_space_required_before_and_after_str), ":"); 3659 semsg(_(e_white_space_required_before_and_after_str_at_str),
3660 ":", *arg);
3660 return FAIL; 3661 return FAIL;
3661 } 3662 }
3662 if (may_get_next_line_error(p, arg, cctx) == FAIL) 3663 if (may_get_next_line_error(p, arg, cctx) == FAIL)
3663 return FAIL; 3664 return FAIL;
3664 *arg = skipwhite(*arg); 3665 *arg = skipwhite(*arg);
3667 { 3668 {
3668 is_slice = TRUE; 3669 is_slice = TRUE;
3669 ++*arg; 3670 ++*arg;
3670 if (!IS_WHITE_OR_NUL(**arg) && **arg != ']') 3671 if (!IS_WHITE_OR_NUL(**arg) && **arg != ']')
3671 { 3672 {
3672 semsg(_(e_white_space_required_before_and_after_str), ":"); 3673 semsg(_(e_white_space_required_before_and_after_str_at_str),
3674 ":", *arg);
3673 return FAIL; 3675 return FAIL;
3674 } 3676 }
3675 *arg = skipwhite(*arg); 3677 *arg = skipwhite(*arg);
3676 if (may_get_next_line_error(p, arg, cctx) == FAIL) 3678 if (may_get_next_line_error(p, arg, cctx) == FAIL)
3677 return FAIL; 3679 return FAIL;
4065 error_white_both(char_u *op, int len) 4067 error_white_both(char_u *op, int len)
4066 { 4068 {
4067 char_u buf[10]; 4069 char_u buf[10];
4068 4070
4069 vim_strncpy(buf, op, len); 4071 vim_strncpy(buf, op, len);
4070 semsg(_(e_white_space_required_before_and_after_str), buf); 4072 semsg(_(e_white_space_required_before_and_after_str_at_str), buf, op);
4071 } 4073 }
4072 4074
4073 /* 4075 /*
4074 * <type>expr7: runtime type check / conversion 4076 * <type>expr7: runtime type check / conversion
4075 */ 4077 */
4432 p = skipwhite(*arg); 4434 p = skipwhite(*arg);
4433 } 4435 }
4434 4436
4435 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[2])) 4437 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[2]))
4436 { 4438 {
4437 semsg(_(e_white_space_required_before_and_after_str), op); 4439 semsg(_(e_white_space_required_before_and_after_str_at_str),
4440 op, *arg);
4438 return FAIL; 4441 return FAIL;
4439 } 4442 }
4440 4443
4441 // TODO: use ppconst if the value is a constant and check 4444 // TODO: use ppconst if the value is a constant and check
4442 // evaluating to bool 4445 // evaluating to bool
4606 p = skipwhite(*arg); 4609 p = skipwhite(*arg);
4607 } 4610 }
4608 4611
4609 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1 + op_falsy])) 4612 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1 + op_falsy]))
4610 { 4613 {
4611 semsg(_(e_white_space_required_before_and_after_str), 4614 semsg(_(e_white_space_required_before_and_after_str_at_str),
4612 op_falsy ? "??" : "?"); 4615 op_falsy ? "??" : "?", *arg);
4613 return FAIL; 4616 return FAIL;
4614 } 4617 }
4615 4618
4616 if (ppconst->pp_used == ppconst_used + 1) 4619 if (ppconst->pp_used == ppconst_used + 1)
4617 { 4620 {
4693 p = skipwhite(*arg); 4696 p = skipwhite(*arg);
4694 } 4697 }
4695 4698
4696 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1])) 4699 if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(p[1]))
4697 { 4700 {
4698 semsg(_(e_white_space_required_before_and_after_str), ":"); 4701 semsg(_(e_white_space_required_before_and_after_str_at_str),
4702 ":", p);
4699 return FAIL; 4703 return FAIL;
4700 } 4704 }
4701 4705
4702 // evaluate the third expression 4706 // evaluate the third expression
4703 if (has_const_expr) 4707 if (has_const_expr)