summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-05 12:44:41 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-05 12:44:41 +0200
commitfdac71c5075062f97f77044e9619fa5c907e0327 (patch)
tree921f26225586ac1b903d3a6b0b58065010f7310d /src/eval.c
parent3c1c9fd94bc80871119a8519f3b881595082a6c0 (diff)
patch 8.2.1372: Vim9: no error for missing white space around operatorv8.2.1372
Problem: Vim9: no error for missing white space around operator. Solution: Check for white space around ? and :.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c
index a9c36ac38c..a7f6086ef6 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2072,7 +2072,7 @@ eval0(
* expr2 ? expr1 : expr1
*
* "arg" must point to the first non-white of the expression.
- * "arg" is advanced to the next non-white after the recognized expression.
+ * "arg" is advanced to just after the recognized expression.
*
* Note: "rettv.v_lock" is not set.
*
@@ -2111,7 +2111,15 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
if (getnext)
*arg = eval_next_line(evalarg_used);
else
+ {
+ if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
+ {
+ error_white_both(p, 1);
+ clear_tv(rettv);
+ return FAIL;
+ }
*arg = p;
+ }
result = FALSE;
if (evaluate)
@@ -2128,6 +2136,12 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
/*
* Get the second variable. Recursive!
*/
+ if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
+ {
+ error_white_both(p, 1);
+ clear_tv(rettv);
+ return FAIL;
+ }
*arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
evalarg_used->eval_flags = result ? orig_flags
: orig_flags & ~EVAL_EVALUATE;
@@ -2148,11 +2162,25 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
if (getnext)
*arg = eval_next_line(evalarg_used);
else
+ {
+ if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
+ {
+ error_white_both(p, 1);
+ clear_tv(rettv);
+ return FAIL;
+ }
*arg = p;
+ }
/*
* Get the third variable. Recursive!
*/
+ if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[1]))
+ {
+ error_white_both(p, 1);
+ clear_tv(rettv);
+ return FAIL;
+ }
*arg = skipwhite_and_linebreak(*arg + 1, evalarg_used);
evalarg_used->eval_flags = !result ? orig_flags
: orig_flags & ~EVAL_EVALUATE;
@@ -2179,7 +2207,7 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
* expr2 || expr2 || expr2 logical OR
*
* "arg" must point to the first non-white of the expression.
- * "arg" is advanced to the next non-white after the recognized expression.
+ * "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/
@@ -2310,7 +2338,7 @@ eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
* expr3 && expr3 && expr3 logical AND
*
* "arg" must point to the first non-white of the expression.
- * "arg" is advanced to the next non-white after the recognized expression.
+ * "arg" is advanced to just after the recognized expression.
*
* Return OK or FAIL.
*/