Patch 8.2.1122
Problem: Vim9: line continuation in dict member not recognized.
Solution: Check for line continuation.
Files: src/eval.c, src/testdir/test_vim9_expr.vim
*** ../vim-8.2.1121/src/eval.c 2020-07-01 18:29:23.681143435 +0200
--- src/eval.c 2020-07-03 21:03:59.062231759 +0200
***************
*** 3362,3368 ****
*
* Get the (first) variable from inside the [].
*/
! *arg = skipwhite(*arg + 1);
if (**arg == ':')
empty1 = TRUE;
else if (eval1(arg, &var1, evalarg) == FAIL) // recursive!
--- 3362,3368 ----
*
* Get the (first) variable from inside the [].
*/
! *arg = skipwhite_and_linebreak(*arg + 1, evalarg);
if (**arg == ':')
empty1 = TRUE;
else if (eval1(arg, &var1, evalarg) == FAIL) // recursive!
***************
*** 3377,3386 ****
/*
* Get the second variable from inside the [:].
*/
if (**arg == ':')
{
range = TRUE;
! *arg = skipwhite(*arg + 1);
if (**arg == ']')
empty2 = TRUE;
else if (eval1(arg, &var2, evalarg) == FAIL) // recursive!
--- 3377,3387 ----
/*
* Get the second variable from inside the [:].
*/
+ *arg = skipwhite_and_linebreak(*arg, evalarg);
if (**arg == ':')
{
range = TRUE;
! *arg = skipwhite_and_linebreak(*arg + 1, evalarg);
if (**arg == ']')
empty2 = TRUE;
else if (eval1(arg, &var2, evalarg) == FAIL) // recursive!
***************
*** 3400,3405 ****
--- 3401,3407 ----
}
// Check for the ']'.
+ *arg = skipwhite_and_linebreak(*arg, evalarg);
if (**arg != ']')
{
if (verbose)
***************
*** 5043,5048 ****
--- 5045,5065 ----
&& (evalarg->eval_flags & EVAL_EVALUATE);
int ret = OK;
dict_T *selfdict = NULL;
+ int check_white = TRUE;
+
+ // When at the end of the line and ".name" follows in the next line then
+ // consume the line break. Only when rettv is a dict.
+ if (rettv->v_type == VAR_DICT)
+ {
+ int getnext;
+ char_u *p = eval_next_non_blank(*arg, evalarg, &getnext);
+
+ if (getnext && *p == '.' && ASCII_ISALPHA(p[1]))
+ {
+ *arg = eval_next_line(evalarg);
+ check_white = FALSE;
+ }
+ }
// "." is ".name" lookup when we found a dict or when evaluating and
// scriptversion is at least 2, where string concatenation is "..".
***************
*** 5054,5060 ****
&& current_sctx.sc_version >= 2)))
|| (**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC
|| rettv->v_type == VAR_PARTIAL)))
! && !VIM_ISWHITE(*(*arg - 1)))
|| (**arg == '-' && (*arg)[1] == '>')))
{
if (**arg == '(')
--- 5071,5077 ----
&& current_sctx.sc_version >= 2)))
|| (**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC
|| rettv->v_type == VAR_PARTIAL)))
! && (!check_white || !VIM_ISWHITE(*(*arg - 1))))
|| (**arg == '-' && (*arg)[1] == '>')))
{
if (**arg == '(')
*** ../vim-8.2.1121/src/testdir/test_vim9_expr.vim 2020-07-01 20:07:11.561328187 +0200
--- src/testdir/test_vim9_expr.vim 2020-07-03 20:53:10.475639032 +0200
***************
*** 1138,1143 ****
--- 1138,1180 ----
call CheckDefExecFailure(["let d: dict<number>", "d = g:list_empty"], 'E1029: Expected dict but got list')
enddef
+ def Test_expr_member_vim9script()
+ let lines =<< trim END
+ vim9script
+ let d = #{one:
+ 'one',
+ two: 'two'}
+ assert_equal('one', d.one)
+ assert_equal('one', d
+ .one)
+ assert_equal('one', d[
+ 'one'
+ ])
+ END
+ CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ let l = [1,
+ 2,
+ 3, 4
+ ]
+ assert_equal(2, l[
+ 1
+ ])
+ assert_equal([2, 3], l[1 : 2])
+ assert_equal([1, 2, 3], l[
+ :
+ 2
+ ])
+ assert_equal([3, 4], l[
+ 2
+ :
+ ])
+ END
+ CheckScriptSuccess(lines)
+ enddef
+
def Test_expr7_option()
" option
set ts=11
*** ../vim-8.2.1121/src/version.c 2020-07-03 18:15:02.830048103 +0200
--- src/version.c 2020-07-03 20:12:31.965617200 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1122,
/**/
--
Mrs Abbott: I'm a paediatrician.
Basil: Feet?
Mrs Abbott: Children.
Sybil: Oh, Basil!
Basil: Well, children have feet, don't they? That's how they move
around, my dear. You must take a look next time, it's most
interesting. (Fawlty Towers)
/// 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 ///