comparison src/eval.c @ 21630:3c6c52fbc8ea v8.2.1365

patch 8.2.1365: Vim9: no error for missing white space around operator Commit: https://github.com/vim/vim/commit/bb1b5e24ecc0abe1fee164e9de13796989eff784 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 5 10:53:21 2020 +0200 patch 8.2.1365: Vim9: no error for missing white space around operator Problem: Vim9: no error for missing white space around operator. Solution: Check for white space. (closes https://github.com/vim/vim/issues/6618)
author Bram Moolenaar <Bram@vim.org>
date Wed, 05 Aug 2020 11:00:08 +0200
parents 1f2066e3975a
children 3a86e41fdffd
comparison
equal deleted inserted replaced
21629:87a1c4717817 21630:3c6c52fbc8ea
2572 { 2572 {
2573 int evaluate; 2573 int evaluate;
2574 int getnext; 2574 int getnext;
2575 char_u *p; 2575 char_u *p;
2576 int op; 2576 int op;
2577 int oplen;
2577 int concat; 2578 int concat;
2578 typval_T var2; 2579 typval_T var2;
2579 2580
2580 // "." is only string concatenation when scriptversion is 1 2581 // "." is only string concatenation when scriptversion is 1
2581 p = eval_next_non_blank(*arg, evalarg, &getnext); 2582 p = eval_next_non_blank(*arg, evalarg, &getnext);
2582 op = *p; 2583 op = *p;
2583 concat = op == '.' && (*(p + 1) == '.' || current_sctx.sc_version < 2); 2584 concat = op == '.' && (*(p + 1) == '.' || current_sctx.sc_version < 2);
2584 if (op != '+' && op != '-' && !concat) 2585 if (op != '+' && op != '-' && !concat)
2585 break; 2586 break;
2586 2587
2588 evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
2587 if (getnext) 2589 if (getnext)
2588 *arg = eval_next_line(evalarg); 2590 *arg = eval_next_line(evalarg);
2589 else 2591 else
2592 {
2593 if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
2594 {
2595 error_white_both(p, 1);
2596 clear_tv(rettv);
2597 return FAIL;
2598 }
2590 *arg = p; 2599 *arg = p;
2591 evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE); 2600 }
2592 if ((op != '+' || (rettv->v_type != VAR_LIST 2601 if ((op != '+' || (rettv->v_type != VAR_LIST
2593 && rettv->v_type != VAR_BLOB)) 2602 && rettv->v_type != VAR_BLOB))
2594 #ifdef FEAT_FLOAT 2603 #ifdef FEAT_FLOAT
2595 && (op == '.' || rettv->v_type != VAR_FLOAT) 2604 && (op == '.' || rettv->v_type != VAR_FLOAT)
2596 #endif 2605 #endif
2611 } 2620 }
2612 2621
2613 /* 2622 /*
2614 * Get the second variable. 2623 * Get the second variable.
2615 */ 2624 */
2616 if (op == '.' && *(*arg + 1) == '.') // .. string concatenation 2625 oplen = (op == '.' && *(*arg + 1) == '.') ? 2 : 1;
2617 ++*arg; 2626 if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[oplen]))
2618 *arg = skipwhite_and_linebreak(*arg + 1, evalarg); 2627 {
2628 error_white_both(p, oplen);
2629 clear_tv(rettv);
2630 return FAIL;
2631 }
2632 *arg = skipwhite_and_linebreak(*arg + oplen, evalarg);
2619 if (eval6(arg, &var2, evalarg, op == '.') == FAIL) 2633 if (eval6(arg, &var2, evalarg, op == '.') == FAIL)
2620 { 2634 {
2621 clear_tv(rettv); 2635 clear_tv(rettv);
2622 return FAIL; 2636 return FAIL;
2623 } 2637 }
3356 emsg(_("E260: Missing name after ->")); 3370 emsg(_("E260: Missing name after ->"));
3357 ret = FAIL; 3371 ret = FAIL;
3358 } 3372 }
3359 else 3373 else
3360 { 3374 {
3375 *arg = skipwhite(*arg);
3361 if (**arg != '(') 3376 if (**arg != '(')
3362 { 3377 {
3363 if (verbose) 3378 if (verbose)
3364 semsg(_(e_missing_paren), name); 3379 semsg(_(e_missing_paren), name);
3365 ret = FAIL; 3380 ret = FAIL;
4839 return len; 4854 return len;
4840 } 4855 }
4841 4856
4842 /* 4857 /*
4843 * Get the length of the name of a function or internal variable. 4858 * Get the length of the name of a function or internal variable.
4844 * "arg" is advanced to the first non-white character after the name. 4859 * "arg" is advanced to after the name.
4845 * Return 0 if something is wrong. 4860 * Return 0 if something is wrong.
4846 */ 4861 */
4847 int 4862 int
4848 get_id_len(char_u **arg) 4863 get_id_len(char_u **arg)
4849 { 4864 {
4865 } 4880 }
4866 if (p == *arg) // no name found 4881 if (p == *arg) // no name found
4867 return 0; 4882 return 0;
4868 4883
4869 len = (int)(p - *arg); 4884 len = (int)(p - *arg);
4870 *arg = skipwhite(p); 4885 *arg = p;
4871 4886
4872 return len; 4887 return len;
4873 } 4888 }
4874 4889
4875 /* 4890 /*