mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Problem: Vim9: no line break allowed inside "cond ? val1 : val2". Solution: Check for operator after line break.
This commit is contained in:
14
src/eval.c
14
src/eval.c
@@ -1892,13 +1892,17 @@ eval0(
|
|||||||
int
|
int
|
||||||
eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||||
{
|
{
|
||||||
|
char_u *p;
|
||||||
|
int getnext;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the first variable.
|
* Get the first variable.
|
||||||
*/
|
*/
|
||||||
if (eval2(arg, rettv, evalarg) == FAIL)
|
if (eval2(arg, rettv, evalarg) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
if ((*arg)[0] == '?')
|
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
||||||
|
if (*p == '?')
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
typval_T var2;
|
typval_T var2;
|
||||||
@@ -1906,6 +1910,9 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *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);
|
||||||
@@ -1942,13 +1949,16 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
|||||||
/*
|
/*
|
||||||
* Check for the ":".
|
* Check for the ":".
|
||||||
*/
|
*/
|
||||||
if ((*arg)[0] != ':')
|
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
||||||
|
if (*p != ':')
|
||||||
{
|
{
|
||||||
emsg(_(e_missing_colon));
|
emsg(_(e_missing_colon));
|
||||||
if (evaluate && result)
|
if (evaluate && result)
|
||||||
clear_tv(rettv);
|
clear_tv(rettv);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
if (getnext)
|
||||||
|
*arg = eval_next_line(evalarg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the third variable. Recursive!
|
* Get the third variable. Recursive!
|
||||||
|
@@ -45,6 +45,27 @@ def Test_expr1()
|
|||||||
assert_equal(function('len'), RetThat)
|
assert_equal(function('len'), RetThat)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_expr1_vimscript()
|
||||||
|
" only checks line continuation
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let var = 1
|
||||||
|
? 'yes'
|
||||||
|
: 'no'
|
||||||
|
assert_equal('yes', var)
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let var = v:false
|
||||||
|
? 'yes'
|
||||||
|
: 'no'
|
||||||
|
assert_equal('no', var)
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
func Test_expr1_fails()
|
func Test_expr1_fails()
|
||||||
call CheckDefFailure(["let x = 1 ? 'one'"], "Missing ':' after '?'")
|
call CheckDefFailure(["let x = 1 ? 'one'"], "Missing ':' after '?'")
|
||||||
call CheckDefFailure(["let x = 1 ? 'one' : xxx"], "E1001:")
|
call CheckDefFailure(["let x = 1 ? 'one' : xxx"], "E1001:")
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
1062,
|
||||||
/**/
|
/**/
|
||||||
1061,
|
1061,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user