Patch 8.2.1062

6 views
Skip to first unread message

Bram Moolenaar

unread,
Jun 26, 2020, 3:28:58 PM6/26/20
to vim...@googlegroups.com

Patch 8.2.1062
Problem: Vim9: no line break allowed inside "cond ? val1 : val2".
Solution: Check for operator after line break.
Files: src/eval.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.1061/src/eval.c 2020-06-24 23:02:36.860095536 +0200
--- src/eval.c 2020-06-26 21:22:27.773859086 +0200
***************
*** 1892,1904 ****
int
eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
{
/*
* Get the first variable.
*/
if (eval2(arg, rettv, evalarg) == FAIL)
return FAIL;

! if ((*arg)[0] == '?')
{
int result;
typval_T var2;
--- 1892,1908 ----
int
eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
{
+ char_u *p;
+ int getnext;
+
/*
* Get the first variable.
*/
if (eval2(arg, rettv, evalarg) == FAIL)
return FAIL;

! p = eval_next_non_blank(*arg, evalarg, &getnext);
! if (*p == '?')
{
int result;
typval_T var2;
***************
*** 1906,1911 ****
--- 1910,1918 ----
int orig_flags;
int evaluate;

+ if (getnext)
+ *arg = eval_next_line(evalarg);
+
if (evalarg == NULL)
{
CLEAR_FIELD(nested_evalarg);
***************
*** 1942,1954 ****
/*
* Check for the ":".
*/
! if ((*arg)[0] != ':')
{
emsg(_(e_missing_colon));
if (evaluate && result)
clear_tv(rettv);
return FAIL;
}

/*
* Get the third variable. Recursive!
--- 1949,1964 ----
/*
* Check for the ":".
*/
! p = eval_next_non_blank(*arg, evalarg, &getnext);
! if (*p != ':')
{
emsg(_(e_missing_colon));
if (evaluate && result)
clear_tv(rettv);
return FAIL;
}
+ if (getnext)
+ *arg = eval_next_line(evalarg);

/*
* Get the third variable. Recursive!
*** ../vim-8.2.1061/src/testdir/test_vim9_expr.vim 2020-06-24 18:37:28.359249374 +0200
--- src/testdir/test_vim9_expr.vim 2020-06-26 21:27:34.308997325 +0200
***************
*** 45,50 ****
--- 45,71 ----
assert_equal(function('len'), RetThat)
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()
call CheckDefFailure(["let x = 1 ? 'one'"], "Missing ':' after '?'")
call CheckDefFailure(["let x = 1 ? 'one' : xxx"], "E1001:")
*** ../vim-8.2.1061/src/version.c 2020-06-26 20:41:35.632844686 +0200
--- src/version.c 2020-06-26 21:28:03.780914590 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1062,
/**/

--
It is illegal to take more than three sips of beer at a time while standing.
[real standing law in Texas, United States of America]

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages