patch 8.2.1326: Vim9: skipping over white space after list

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.
diff --git a/src/dict.c b/src/dict.c
index eedaf42..019227f 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -838,6 +838,10 @@
 		: 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 451bb16..119b7cc 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1913,27 +1913,28 @@
     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 @@
 
     p = skipwhite(arg);
     ret = eval1(&p, rettv, evalarg);
+    p = skipwhite(p);
 
     if (ret == FAIL || !ends_excmd2(arg, p))
     {
@@ -2107,6 +2109,8 @@
 
 	if (getnext)
 	    *arg = eval_next_line(evalarg_used);
+	else
+	    *arg = p;
 
 	result = FALSE;
 	if (evaluate)
@@ -2142,6 +2146,8 @@
 	}
 	if (getnext)
 	    *arg = eval_next_line(evalarg_used);
+	else
+	    *arg = p;
 
 	/*
 	 * Get the third variable.  Recursive!
@@ -2234,6 +2240,8 @@
 	{
 	    if (getnext)
 		*arg = eval_next_line(evalarg_used);
+	    else
+		*arg = p;
 
 	    /*
 	     * Get the second variable.
@@ -2349,6 +2357,8 @@
 	{
 	    if (getnext)
 		*arg = eval_next_line(evalarg_used);
+	    else
+		*arg = p;
 
 	    /*
 	     * Get the second variable.
@@ -2575,6 +2585,8 @@
 
 	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 @@
 	int	    evaluate;
 	int	    getnext;
 	typval_T    var2;
+	char_u	    *p;
 	int	    op;
 	varnumber_T n1, n2;
 #ifdef FEAT_FLOAT
@@ -2763,12 +2776,15 @@
 #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 @@
 	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 @@
 	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 @@
 	    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 9a334ae..5c2f60e 100644
--- a/src/list.c
+++ b/src/list.c
@@ -1199,7 +1199,7 @@
 	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 @@
 	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 9aa830b..7aaeeb7 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1355,7 +1355,7 @@
   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 c72da92..b90aa5f 100644
--- a/src/testdir/test_gn.vim
+++ b/src/testdir/test_gn.vim
@@ -120,7 +120,7 @@
   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 00b956a..30dfc66 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -588,7 +588,7 @@
 	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 33fdab4..bbcafa8 100644
--- a/src/testdir/test_tabpage.vim
+++ b/src/testdir/test_tabpage.vim
@@ -350,7 +350,7 @@
     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 6eb6fbb..54de3f8 100644
--- a/src/testdir/test_textobjects.vim
+++ b/src/testdir/test_textobjects.vim
@@ -201,28 +201,28 @@
   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 d5f67b4..9db5275 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -1219,7 +1219,7 @@
   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 343c9cd..de0cdb7 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -642,6 +642,10 @@
 	    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 02fa087..c37fbe4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1326,
+/**/
     1325,
 /**/
     1324,