summaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-05 10:53:21 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-05 10:53:21 +0200
commitbb1b5e24ecc0abe1fee164e9de13796989eff784 (patch)
treecd42f7d7632663f57a56c31026392f9d26f72444 /src/eval.c
parent282f9c64e570e832d3eba12950da15c9f1a40f06 (diff)
downloadvim-git-bb1b5e24ecc0abe1fee164e9de13796989eff784.tar.gz
patch 8.2.1365: Vim9: no error for missing white space around operatorv8.2.1365
Problem: Vim9: no error for missing white space around operator. Solution: Check for white space. (closes #6618)
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/eval.c b/src/eval.c
index cfa86ef2c..3c4e5bdef 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2574,6 +2574,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
int getnext;
char_u *p;
int op;
+ int oplen;
int concat;
typval_T var2;
@@ -2584,11 +2585,19 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
if (op != '+' && op != '-' && !concat)
break;
+ evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if (getnext)
*arg = eval_next_line(evalarg);
else
+ {
+ if (evaluate && in_vim9script() && !VIM_ISWHITE(**arg))
+ {
+ error_white_both(p, 1);
+ clear_tv(rettv);
+ return FAIL;
+ }
*arg = p;
- evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
+ }
if ((op != '+' || (rettv->v_type != VAR_LIST
&& rettv->v_type != VAR_BLOB))
#ifdef FEAT_FLOAT
@@ -2613,9 +2622,14 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
/*
* Get the second variable.
*/
- if (op == '.' && *(*arg + 1) == '.') // .. string concatenation
- ++*arg;
- *arg = skipwhite_and_linebreak(*arg + 1, evalarg);
+ oplen = (op == '.' && *(*arg + 1) == '.') ? 2 : 1;
+ if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[oplen]))
+ {
+ error_white_both(p, oplen);
+ clear_tv(rettv);
+ return FAIL;
+ }
+ *arg = skipwhite_and_linebreak(*arg + oplen, evalarg);
if (eval6(arg, &var2, evalarg, op == '.') == FAIL)
{
clear_tv(rettv);
@@ -3358,6 +3372,7 @@ eval_method(
}
else
{
+ *arg = skipwhite(*arg);
if (**arg != '(')
{
if (verbose)
@@ -4841,7 +4856,7 @@ get_env_len(char_u **arg)
/*
* Get the length of the name of a function or internal variable.
- * "arg" is advanced to the first non-white character after the name.
+ * "arg" is advanced to after the name.
* Return 0 if something is wrong.
*/
int
@@ -4867,7 +4882,7 @@ get_id_len(char_u **arg)
return 0;
len = (int)(p - *arg);
- *arg = skipwhite(p);
+ *arg = p;
return len;
}