0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.1371: Vim9: no error for missing white space around operator

Problem:    Vim9: no error for missing white space around operator.
Solution:   Check for white space around && and ||.
This commit is contained in:
Bram Moolenaar
2020-08-05 12:32:38 +02:00
parent c753478b82
commit 3c1c9fd94b
3 changed files with 64 additions and 0 deletions

View File

@@ -2242,11 +2242,25 @@ eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
if (getnext) if (getnext)
*arg = eval_next_line(evalarg_used); *arg = eval_next_line(evalarg_used);
else else
{
if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
{
error_white_both(p, 2);
clear_tv(rettv);
return FAIL;
}
*arg = p; *arg = p;
}
/* /*
* Get the second variable. * Get the second variable.
*/ */
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))
{
error_white_both(p, 2);
clear_tv(rettv);
return FAIL;
}
*arg = skipwhite_and_linebreak(*arg + 2, evalarg_used); *arg = skipwhite_and_linebreak(*arg + 2, evalarg_used);
evalarg_used->eval_flags = !result ? orig_flags evalarg_used->eval_flags = !result ? orig_flags
: orig_flags & ~EVAL_EVALUATE; : orig_flags & ~EVAL_EVALUATE;
@@ -2359,11 +2373,25 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
if (getnext) if (getnext)
*arg = eval_next_line(evalarg_used); *arg = eval_next_line(evalarg_used);
else else
{
if (evaluate && in_vim9script() && !VIM_ISWHITE(p[-1]))
{
error_white_both(p, 2);
clear_tv(rettv);
return FAIL;
}
*arg = p; *arg = p;
}
/* /*
* Get the second variable. * Get the second variable.
*/ */
if (evaluate && in_vim9script() && !IS_WHITE_OR_NUL((*arg)[2]))
{
error_white_both(p, 2);
clear_tv(rettv);
return FAIL;
}
*arg = skipwhite_and_linebreak(*arg + 2, evalarg_used); *arg = skipwhite_and_linebreak(*arg + 2, evalarg_used);
evalarg_used->eval_flags = result ? orig_flags evalarg_used->eval_flags = result ? orig_flags
: orig_flags & ~EVAL_EVALUATE; : orig_flags & ~EVAL_EVALUATE;

View File

@@ -175,6 +175,23 @@ def Test_expr2_vimscript()
END END
CheckScriptSuccess(lines) CheckScriptSuccess(lines)
# check white space
lines =<< trim END
vim9script
let var = v:true||v:true
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
let var = v:true ||v:true
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
let var = v:true|| v:true
END
CheckScriptFailure(lines, 'E1004:')
# check keeping the value # check keeping the value
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -279,6 +296,23 @@ def Test_expr3_vimscript()
END END
CheckScriptSuccess(lines) CheckScriptSuccess(lines)
# check white space
lines =<< trim END
vim9script
let var = v:true&&v:true
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
let var = v:true &&v:true
END
CheckScriptFailure(lines, 'E1004:')
lines =<< trim END
vim9script
let var = v:true&& v:true
END
CheckScriptFailure(lines, 'E1004:')
# check keeping the value # check keeping the value
lines =<< trim END lines =<< trim END
vim9script vim9script

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1371,
/**/ /**/
1370, 1370,
/**/ /**/