summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-30 20:08:50 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-30 20:08:50 +0200
commit9d489566815d7913afc5dfc2a772bacede3970fb (patch)
treeeff105e7214186b0a4bf31296d06d7d89926935a
parentea2d8d25718836bf627b67b7fcd28a1e528bb7b9 (diff)
downloadvim-git-9d489566815d7913afc5dfc2a772bacede3970fb.tar.gz
patch 8.2.1326: Vim9: skipping over white space after listv8.2.1326
Problem: Vim9: skipping over white space after list. Solution: Do not skip white space, a following [] would be misinterpreted. (closes #6552) Fix a few side effects.
-rw-r--r--src/dict.c4
-rw-r--r--src/eval.c41
-rw-r--r--src/list.c4
-rw-r--r--src/testdir/test_functions.vim2
-rw-r--r--src/testdir/test_gn.vim2
-rw-r--r--src/testdir/test_popupwin.vim2
-rw-r--r--src/testdir/test_tabpage.vim2
-rw-r--r--src/testdir/test_textobjects.vim34
-rw-r--r--src/testdir/test_textprop.vim2
-rw-r--r--src/userfunc.c4
-rw-r--r--src/version.c2
11 files changed, 62 insertions, 37 deletions
diff --git a/src/dict.c b/src/dict.c
index eedaf4268..019227f10 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -838,6 +838,10 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
: eval1(arg, &tvkey, evalarg)) == FAIL) // recursive!
goto failret;
+ // The colon should come right after the key, but this wasn't checked
+ // previously, so only require it in Vim9 script.
+ if (!vim9script)
+ *arg = skipwhite(*arg);
if (**arg != ':')
{
if (evaluate)
diff --git a/src/eval.c b/src/eval.c
index 451bb16b7..119b7cc18 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1913,27 +1913,28 @@ eval_func(
char_u *
eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
{
+ char_u *p = skipwhite(arg);
+
*getnext = FALSE;
if (in_vim9script()
&& evalarg != NULL
&& (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL)
- && (*arg == NUL || (VIM_ISWHITE(arg[-1])
- && vim9_comment_start(arg))))
+ && (*p == NUL || (VIM_ISWHITE(p[-1]) && vim9_comment_start(p))))
{
- char_u *p;
+ char_u *next;
if (evalarg->eval_cookie != NULL)
- p = getline_peek(evalarg->eval_getline, evalarg->eval_cookie);
+ next = getline_peek(evalarg->eval_getline, evalarg->eval_cookie);
else
- p = peek_next_line_from_context(evalarg->eval_cctx);
+ next = peek_next_line_from_context(evalarg->eval_cctx);
- if (p != NULL)
+ if (next != NULL)
{
*getnext = TRUE;
- return skipwhite(p);
+ return skipwhite(next);
}
}
- return arg;
+ return p;
}
/*
@@ -2039,6 +2040,7 @@ eval0(
p = skipwhite(arg);
ret = eval1(&p, rettv, evalarg);
+ p = skipwhite(p);
if (ret == FAIL || !ends_excmd2(arg, p))
{
@@ -2107,6 +2109,8 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
if (getnext)
*arg = eval_next_line(evalarg_used);
+ else
+ *arg = p;
result = FALSE;
if (evaluate)
@@ -2142,6 +2146,8 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
}
if (getnext)
*arg = eval_next_line(evalarg_used);
+ else
+ *arg = p;
/*
* Get the third variable. Recursive!
@@ -2234,6 +2240,8 @@ eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
{
if (getnext)
*arg = eval_next_line(evalarg_used);
+ else
+ *arg = p;
/*
* Get the second variable.
@@ -2349,6 +2357,8 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
{
if (getnext)
*arg = eval_next_line(evalarg_used);
+ else
+ *arg = p;
/*
* Get the second variable.
@@ -2575,6 +2585,8 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
if (getnext)
*arg = eval_next_line(evalarg);
+ else
+ *arg = p;
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
if ((op != '+' || (rettv->v_type != VAR_LIST
&& rettv->v_type != VAR_BLOB))
@@ -2756,6 +2768,7 @@ eval6(
int evaluate;
int getnext;
typval_T var2;
+ char_u *p;
int op;
varnumber_T n1, n2;
#ifdef FEAT_FLOAT
@@ -2763,12 +2776,15 @@ eval6(
#endif
int error;
- op = *eval_next_non_blank(*arg, evalarg, &getnext);
+ p = eval_next_non_blank(*arg, evalarg, &getnext);
+ op = *p;
if (op != '*' && op != '/' && op != '%')
break;
if (getnext)
*arg = eval_next_line(evalarg);
+ else
+ *arg = p;
#ifdef FEAT_FLOAT
f1 = 0;
@@ -3115,8 +3131,6 @@ eval7(
vim_free(alias);
}
- *arg = skipwhite(*arg);
-
// Handle following '[', '(' and '.' for expr[expr], expr.name,
// expr(expr), expr->name(expr)
if (ret == OK)
@@ -5152,7 +5166,7 @@ handle_subscript(
p = eval_next_non_blank(*arg, evalarg, &getnext);
if (getnext
&& ((rettv->v_type == VAR_DICT && *p == '.' && eval_isdictc(p[1]))
- || (*p == '-' && p[1] == '>'
+ || (p[0] == '-' && p[1] == '>'
&& (p[2] == '{' || ASCII_ISALPHA(p[2])))))
{
*arg = eval_next_line(evalarg);
@@ -5178,8 +5192,9 @@ handle_subscript(
dict_unref(selfdict);
selfdict = NULL;
}
- else if (**arg == '-' && (*arg)[1] == '>')
+ else if (p[0] == '-' && p[1] == '>')
{
+ *arg = p;
if (ret == OK)
{
if ((*arg)[2] == '{')
diff --git a/src/list.c b/src/list.c
index 9a334ae45..5c2f60ef7 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1199,7 +1199,7 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
had_comma = **arg == ',';
if (had_comma)
{
- if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
+ if (vim9script && !IS_WHITE_OR_NUL((*arg)[1]))
{
semsg(_(e_white_after), ",");
goto failret;
@@ -1231,7 +1231,7 @@ failret:
return FAIL;
}
- *arg = skipwhite(*arg + 1);
+ *arg += 1;
if (evaluate)
rettv_list_set(rettv, l);
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 9aa830b2f..7aaeeb7ae 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1355,7 +1355,7 @@ func Test_input_func()
func! Tcomplete(arglead, cmdline, pos)
return "item1\nitem2\nitem3"
endfunc
- call feedkeys(":let c = input('Q? ', '' , 'custom,Tcomplete')\<CR>"
+ call feedkeys(":let c = input('Q? ', '', 'custom,Tcomplete')\<CR>"
\ .. "\<C-A>\<CR>", 'xt')
delfunc Tcomplete
call assert_equal('item1 item2 item3', c)
diff --git a/src/testdir/test_gn.vim b/src/testdir/test_gn.vim
index c72da925a..b90aa5f1d 100644
--- a/src/testdir/test_gn.vim
+++ b/src/testdir/test_gn.vim
@@ -120,7 +120,7 @@ func Test_gn_command()
sil! %d_
" search using the \zs atom
- call setline(1, [' nnoremap', '' , 'nnoremap'])
+ call setline(1, [' nnoremap', '', 'nnoremap'])
set wrapscan&vim
let @/ = '\_s\zsnnoremap'
$
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 00b956a9e..30dfc6693 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -588,7 +588,7 @@ func Test_popup_drag_termwin()
call setline(1, range(100))
for nr in range(7)
call setline(nr * 12 + 1, "fold {{{")
- call setline(nr * 12 + 11 , "end }}}")
+ call setline(nr * 12 + 11, "end }}}")
endfor
%foldclose
set shell=/bin/sh noruler
diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim
index 33fdab478..bbcafa8eb 100644
--- a/src/testdir/test_tabpage.vim
+++ b/src/testdir/test_tabpage.vim
@@ -350,7 +350,7 @@ function Test_tabpage_with_tabprevious()
call Check_tab_count(6, cmd . ' 3', 3)
call Check_tab_count(6, cmd . ' 8', 4)
for n in range(2)
- for c in ['0', '.+3', '+', '+2' , '-', '-2' , '$', '+99', '-99']
+ for c in ['0', '.+3', '+', '+2', '-', '-2', '$', '+99', '-99']
if n == 0 " pre count
let entire_cmd = c . cmd
let err_code = 'E16:'
diff --git a/src/testdir/test_textobjects.vim b/src/testdir/test_textobjects.vim
index 6eb6fbbf3..54de3f89d 100644
--- a/src/testdir/test_textobjects.vim
+++ b/src/testdir/test_textobjects.vim
@@ -201,28 +201,28 @@ func Test_match()
call assert_equal("c", matchstr("abcd", ".", 2, 0))
call assert_equal("a", matchstr("abcd", ".", 0, -1))
call assert_equal(-1, match("abcd", ".", 0, 5))
- call assert_equal(0 , match("abcd", ".", 0, -1))
- call assert_equal(0 , match('abc', '.', 0, 1))
- call assert_equal(1 , match('abc', '.', 0, 2))
- call assert_equal(2 , match('abc', '.', 0, 3))
+ call assert_equal(0, match("abcd", ".", 0, -1))
+ call assert_equal(0, match('abc', '.', 0, 1))
+ call assert_equal(1, match('abc', '.', 0, 2))
+ call assert_equal(2, match('abc', '.', 0, 3))
call assert_equal(-1, match('abc', '.', 0, 4))
- call assert_equal(1 , match('abc', '.', 1, 1))
- call assert_equal(2 , match('abc', '.', 2, 1))
+ call assert_equal(1, match('abc', '.', 1, 1))
+ call assert_equal(2, match('abc', '.', 2, 1))
call assert_equal(-1, match('abc', '.', 3, 1))
- call assert_equal(3 , match('abc', '$', 0, 1))
+ call assert_equal(3, match('abc', '$', 0, 1))
call assert_equal(-1, match('abc', '$', 0, 2))
- call assert_equal(3 , match('abc', '$', 1, 1))
- call assert_equal(3 , match('abc', '$', 2, 1))
- call assert_equal(3 , match('abc', '$', 3, 1))
+ call assert_equal(3, match('abc', '$', 1, 1))
+ call assert_equal(3, match('abc', '$', 2, 1))
+ call assert_equal(3, match('abc', '$', 3, 1))
call assert_equal(-1, match('abc', '$', 4, 1))
- call assert_equal(0 , match('abc', '\zs', 0, 1))
- call assert_equal(1 , match('abc', '\zs', 0, 2))
- call assert_equal(2 , match('abc', '\zs', 0, 3))
- call assert_equal(3 , match('abc', '\zs', 0, 4))
+ call assert_equal(0, match('abc', '\zs', 0, 1))
+ call assert_equal(1, match('abc', '\zs', 0, 2))
+ call assert_equal(2, match('abc', '\zs', 0, 3))
+ call assert_equal(3, match('abc', '\zs', 0, 4))
call assert_equal(-1, match('abc', '\zs', 0, 5))
- call assert_equal(1 , match('abc', '\zs', 1, 1))
- call assert_equal(2 , match('abc', '\zs', 2, 1))
- call assert_equal(3 , match('abc', '\zs', 3, 1))
+ call assert_equal(1, match('abc', '\zs', 1, 1))
+ call assert_equal(2, match('abc', '\zs', 2, 1))
+ call assert_equal(3, match('abc', '\zs', 3, 1))
call assert_equal(-1, match('abc', '\zs', 4, 1))
endfunc
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index d5f67b49b..9db5275d5 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -1219,7 +1219,7 @@ func Test_prop_func_invalid_args()
call assert_fails('call prop_find({}, "x")', 'E474:')
call assert_fails('call prop_find({"lnum" : -2})', 'E16:')
call assert_fails('call prop_list(1, [])', 'E715:')
- call assert_fails('call prop_list(-1 , {})', 'E16:')
+ call assert_fails('call prop_list(-1, {})', 'E16:')
call assert_fails('call prop_remove([])', 'E474:')
call assert_fails('call prop_remove({}, -2)', 'E16:')
call assert_fails('call prop_remove({})', 'E968:')
diff --git a/src/userfunc.c b/src/userfunc.c
index 343c9cd2e..de0cdb7ea 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -642,6 +642,10 @@ get_func_tv(
break;
}
++argcount;
+ // The comma should come right after the argument, but this wasn't
+ // checked previously, thus only enforce it in Vim9 script.
+ if (!in_vim9script())
+ argp = skipwhite(argp);
if (*argp != ',')
break;
}
diff --git a/src/version.c b/src/version.c
index 02fa08780..c37fbe46f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1326,
+/**/
1325,
/**/
1324,