]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0230: no error for comma missing in list in :def function v9.0.0230
authorBram Moolenaar <Bram@vim.org>
Sat, 20 Aug 2022 13:51:17 +0000 (14:51 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 20 Aug 2022 13:51:17 +0000 (14:51 +0100)
Problem:    No error for comma missing in list in :def function.
Solution:   Check for missing comma. (closes #10943)

src/testdir/test_vim9_assign.vim
src/testdir/test_vim9_disassemble.vim
src/testdir/test_vim9_expr.vim
src/testdir/test_vim9_func.vim
src/testdir/test_vim9_script.vim
src/version.c
src/vim9expr.c

index df5fc7fe609f22425e6b1b8b7778c0796bcdedb0..b1ff392149125149b695d3098363ab86a05efcbe 100644 (file)
@@ -2128,7 +2128,7 @@ def Test_var_declaration_fails()
                'floats', 'floot',
                'funcs', 'funk',
                'jobs', 'jop',
-               'lists', 'last'
+               'lists', 'last',
                'numbers', 'numbar',
                'strings', 'strung',
                'voids', 'viod']
@@ -2439,11 +2439,11 @@ def Test_unlet()
     ], 'E1105:', 2)
 
   v9.CheckDefExecFailure([
-    'g:dd = {"a": 1, 2: 2}'
+    'g:dd = {"a": 1, 2: 2}',
     'unlet g:dd[0z11]',
     ], 'E1029:', 2)
   v9.CheckDefExecFailure([
-    'g:str = "a string"'
+    'g:str = "a string"',
     'unlet g:str[0]',
     ], 'E1148: Cannot index a string', 2)
 
index c1800c31285d4c5e9efc2955d9c5f471a0c73f65..9334d2410c80ec69295cb1af852eb8f80a5df2be 100644 (file)
@@ -2106,7 +2106,7 @@ def Test_disassemble_compare()
              '  var aDict = {x: 2}',
              floatDecl,
              '  if ' .. case[0],
-             '    echo 42'
+             '    echo 42',
              '  endif',
              'enddef'], 'Xdisassemble')
     source Xdisassemble
@@ -2163,7 +2163,7 @@ def Test_disassemble_compare_const()
   for case in cases
     writefile(['def TestCase' .. nr .. '()',
              '  if ' .. case[0],
-             '    echo 42'
+             '    echo 42',
              '  endif',
              'enddef'], 'Xdisassemble')
     source Xdisassemble
index f30cd8da1945a1dcb8e491674d62702331b42ade..9bb053fe7639b1197704f37270ef31b456ce6ead 100644 (file)
@@ -1876,9 +1876,9 @@ def Test_expr7()
 
   if has('float')
     v9.CheckDefExecAndScriptFailure([
-          'g:one = 1.0'
-          'g:two = 2.0'
-          'echo g:one % g:two'
+          'g:one = 1.0',
+          'g:two = 2.0',
+          'echo g:one % g:two',
           ], 'E804', 3)
   endif
 
@@ -2490,6 +2490,7 @@ def Test_expr9_lambda()
 
   v9.CheckDefAndScriptSuccess(['var Fx = (a) => [0,', ' 1]'])
   v9.CheckDefAndScriptFailure(['var Fx = (a) => [0', ' 1]'], 'E696:', 2)
+  v9.CheckDefAndScriptFailure(['var l = [1 2]'], 'E696:', 1)
 
   # no error for existing script variable when checking for lambda
   lines =<< trim END
index 4011d7fe160facfc5423e66ba53e30613330387f..a88ba8648550acbb35cdcf1d12b6d56a1c04f1ea 100644 (file)
@@ -440,22 +440,22 @@ def Test_missing_return()
                    '    echo "no return"',
                    '  else',
                    '    return 0',
-                   '  endif'
+                   '  endif',
                    'enddef'], 'E1027:')
   v9.CheckDefFailure(['def Missing(): number',
                    '  if g:cond',
                    '    return 1',
                    '  else',
                    '    echo "no return"',
-                   '  endif'
+                   '  endif',
                    'enddef'], 'E1027:')
   v9.CheckDefFailure(['def Missing(): number',
                    '  if g:cond',
                    '    return 1',
                    '  else',
                    '    return 2',
-                   '  endif'
-                   '  return 3'
+                   '  endif',
+                   '  return 3',
                    'enddef'], 'E1095:')
 enddef
 
@@ -1496,7 +1496,7 @@ enddef
 
 def Test_lambda_uses_assigned_var()
   v9.CheckDefSuccess([
-        'var x: any = "aaa"'
+        'var x: any = "aaa"',
         'x = filter(["bbb"], (_, v) => v =~ x)'])
 enddef
 
index 597e31ec1c26d4720f9d8400b8b45e1b4b6fe3b8..d0785dcf893d6109c61965ced234975825ad363b 100644 (file)
@@ -3274,7 +3274,7 @@ def Test_vim9_comment_not_compiled()
 
   v9.CheckScriptSuccess([
       'vim9script',
-      'new'
+      'new',
       'setline(1, ["# define pat", "last"])',
       ':$',
       'dsearch /pat/ #comment',
@@ -3283,7 +3283,7 @@ def Test_vim9_comment_not_compiled()
 
   v9.CheckScriptFailure([
       'vim9script',
-      'new'
+      'new',
       'setline(1, ["# define pat", "last"])',
       ':$',
       'dsearch /pat/#comment',
index 412b3e83eaaed7059ccf0e51e780f5c8fdb309d1..9ce33cdbc83b22fee050d2be804894d2686945c9 100644 (file)
@@ -731,6 +731,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    230,
 /**/
     229,
 /**/
index 8cd095c1a796c1ea2ea9d8ee462316ab7cc656f3..370dce315c878edc637bee2d22004c8589544790 100644 (file)
@@ -975,6 +975,7 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
     int                count = 0;
     int                is_const;
     int                is_all_const = TRUE;    // reset when non-const encountered
+    int                must_end = FALSE;
 
     for (;;)
     {
@@ -993,6 +994,11 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
            ++p;
            break;
        }
+       if (must_end)
+       {
+           semsg(_(e_missing_comma_in_list_str), p);
+           return FAIL;
+       }
        if (compile_expr0_ext(&p, cctx, &is_const) == FAIL)
            return FAIL;
        if (!is_const)
@@ -1007,6 +1013,8 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
                return FAIL;
            }
        }
+       else
+           must_end = TRUE;
        whitep = p;
        p = skipwhite(p);
     }