* 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.
*
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)
/*
* 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;
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;
* 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.
*/
* 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.
*/
enddef
def Test_expr1_vimscript()
- # only checks line continuation
+ # check line continuation
let lines =<< trim END
vim9script
let var = 1
assert_equal('no', var)
END
CheckScriptSuccess(lines)
+
+ # check white space
+ lines =<< trim END
+ vim9script
+ let var = v:true?1:2
+ END
+ CheckScriptFailure(lines, 'E1004:')
+ lines =<< trim END
+ vim9script
+ let var = v:true? 1 : 2
+ END
+ CheckScriptFailure(lines, 'E1004:')
+ lines =<< trim END
+ vim9script
+ let var = v:true ?1 : 2
+ END
+ CheckScriptFailure(lines, 'E1004:')
+ lines =<< trim END
+ vim9script
+ let var = v:true ? 1: 2
+ END
+ CheckScriptFailure(lines, 'E1004:')
+ lines =<< trim END
+ vim9script
+ let var = v:true ? 1 :2
+ END
+ CheckScriptFailure(lines, 'E1004:')
enddef
func Test_expr1_fails()