mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.1063: Vim9: no line break allowed before || or &&
Problem: Vim9: no line break allowed before || or &&. Solution: Check for operator after line break.
This commit is contained in:
20
src/eval.c
20
src/eval.c
@@ -1991,6 +1991,8 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
static int
|
static int
|
||||||
eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||||
{
|
{
|
||||||
|
char_u *p;
|
||||||
|
int getnext;
|
||||||
typval_T var2;
|
typval_T var2;
|
||||||
long result;
|
long result;
|
||||||
int first;
|
int first;
|
||||||
@@ -2007,12 +2009,16 @@ eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
*/
|
*/
|
||||||
first = TRUE;
|
first = TRUE;
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
while ((*arg)[0] == '|' && (*arg)[1] == '|')
|
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
||||||
|
while (p[0] == '|' && p[1] == '|')
|
||||||
{
|
{
|
||||||
evalarg_T nested_evalarg;
|
evalarg_T nested_evalarg;
|
||||||
int evaluate;
|
int evaluate;
|
||||||
int orig_flags;
|
int orig_flags;
|
||||||
|
|
||||||
|
if (getnext)
|
||||||
|
*arg = eval_next_line(evalarg);
|
||||||
|
|
||||||
if (evalarg == NULL)
|
if (evalarg == NULL)
|
||||||
{
|
{
|
||||||
CLEAR_FIELD(nested_evalarg);
|
CLEAR_FIELD(nested_evalarg);
|
||||||
@@ -2061,6 +2067,8 @@ eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
rettv->v_type = VAR_NUMBER;
|
rettv->v_type = VAR_NUMBER;
|
||||||
rettv->vval.v_number = result;
|
rettv->vval.v_number = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -2078,6 +2086,8 @@ eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
static int
|
static int
|
||||||
eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||||
{
|
{
|
||||||
|
char_u *p;
|
||||||
|
int getnext;
|
||||||
typval_T var2;
|
typval_T var2;
|
||||||
long result;
|
long result;
|
||||||
int first;
|
int first;
|
||||||
@@ -2094,12 +2104,16 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
*/
|
*/
|
||||||
first = TRUE;
|
first = TRUE;
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
while ((*arg)[0] == '&' && (*arg)[1] == '&')
|
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
||||||
|
while (p[0] == '&' && p[1] == '&')
|
||||||
{
|
{
|
||||||
evalarg_T nested_evalarg;
|
evalarg_T nested_evalarg;
|
||||||
int orig_flags;
|
int orig_flags;
|
||||||
int evaluate;
|
int evaluate;
|
||||||
|
|
||||||
|
if (getnext)
|
||||||
|
*arg = eval_next_line(evalarg);
|
||||||
|
|
||||||
if (evalarg == NULL)
|
if (evalarg == NULL)
|
||||||
{
|
{
|
||||||
CLEAR_FIELD(nested_evalarg);
|
CLEAR_FIELD(nested_evalarg);
|
||||||
@@ -2147,6 +2161,8 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
rettv->v_type = VAR_NUMBER;
|
rettv->v_type = VAR_NUMBER;
|
||||||
rettv->vval.v_number = result;
|
rettv->vval.v_number = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
@@ -117,6 +117,26 @@ def Test_expr2()
|
|||||||
assert_equal([[], '', 0], g:vals)
|
assert_equal([[], '', 0], g:vals)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_expr2_vimscript()
|
||||||
|
" only checks line continuation
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let var = 0
|
||||||
|
|| 1
|
||||||
|
assert_equal(1, var)
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let var = v:false
|
||||||
|
|| v:true
|
||||||
|
|| v:false
|
||||||
|
assert_equal(1, var)
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
func Test_expr2_fails()
|
func Test_expr2_fails()
|
||||||
let msg = "white space required before and after '||'"
|
let msg = "white space required before and after '||'"
|
||||||
call CheckDefFailure(["let x = 1||2"], msg)
|
call CheckDefFailure(["let x = 1||2"], msg)
|
||||||
@@ -160,6 +180,26 @@ def Test_expr3()
|
|||||||
assert_equal([[1], 'z', 0], g:vals)
|
assert_equal([[1], 'z', 0], g:vals)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_expr3_vimscript()
|
||||||
|
" only checks line continuation
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let var = 0
|
||||||
|
&& 1
|
||||||
|
assert_equal(0, var)
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let var = v:true
|
||||||
|
&& v:true
|
||||||
|
&& v:true
|
||||||
|
assert_equal(1, var)
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
func Test_expr3_fails()
|
func Test_expr3_fails()
|
||||||
let msg = "white space required before and after '&&'"
|
let msg = "white space required before and after '&&'"
|
||||||
call CheckDefFailure(["let x = 1&&2"], msg)
|
call CheckDefFailure(["let x = 1&&2"], msg)
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
1063,
|
||||||
/**/
|
/**/
|
||||||
1062,
|
1062,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user