Patch 9.0.0230
Problem:    No error for comma missing in list in :def function.
Solution:   Check for missing comma. (closes #10943)
Files:      src/vim9expr.c, src/testdir/test_vim9_expr.vim,
            src/testdir/test_vim9_assign.vim,
            src/testdir/test_vim9_disassemble.vim,
            src/testdir/test_vim9_func.vim, src/testdir/test_vim9_script.vim


*** ../vim-9.0.0229/src/vim9expr.c      2022-08-16 16:09:53.599527502 +0100
--- src/vim9expr.c      2022-08-20 14:34:47.447637705 +0100
***************
*** 975,980 ****
--- 975,981 ----
      int               count = 0;
      int               is_const;
      int               is_all_const = TRUE;    // reset when non-const 
encountered
+     int               must_end = FALSE;
  
      for (;;)
      {
***************
*** 993,998 ****
--- 994,1004 ----
            ++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,1012 ****
--- 1013,1020 ----
                return FAIL;
            }
        }
+       else
+           must_end = TRUE;
        whitep = p;
        p = skipwhite(p);
      }
*** ../vim-9.0.0229/src/testdir/test_vim9_expr.vim      2022-08-06 
11:35:24.892762681 +0100
--- src/testdir/test_vim9_expr.vim      2022-08-20 14:38:54.410919106 +0100
***************
*** 1876,1884 ****
  
    if has('float')
      v9.CheckDefExecAndScriptFailure([
!           'g:one = 1.0'
!           'g:two = 2.0'
!           'echo g:one % g:two'
            ], 'E804', 3)
    endif
  
--- 1876,1884 ----
  
    if has('float')
      v9.CheckDefExecAndScriptFailure([
!           'g:one = 1.0',
!           'g:two = 2.0',
!           'echo g:one % g:two',
            ], 'E804', 3)
    endif
  
***************
*** 2490,2495 ****
--- 2490,2496 ----
  
    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
*** ../vim-9.0.0229/src/testdir/test_vim9_assign.vim    2022-08-20 
12:07:55.098022792 +0100
--- src/testdir/test_vim9_assign.vim    2022-08-20 14:46:08.672960469 +0100
***************
*** 2128,2134 ****
                 'floats', 'floot',
                 'funcs', 'funk',
                 'jobs', 'jop',
!                'lists', 'last'
                 'numbers', 'numbar',
                 'strings', 'strung',
                 'voids', 'viod']
--- 2128,2134 ----
                 'floats', 'floot',
                 'funcs', 'funk',
                 'jobs', 'jop',
!                'lists', 'last',
                 'numbers', 'numbar',
                 'strings', 'strung',
                 'voids', 'viod']
***************
*** 2439,2449 ****
      ], 'E1105:', 2)
  
    v9.CheckDefExecFailure([
!     'g:dd = {"a": 1, 2: 2}'
      'unlet g:dd[0z11]',
      ], 'E1029:', 2)
    v9.CheckDefExecFailure([
!     'g:str = "a string"'
      'unlet g:str[0]',
      ], 'E1148: Cannot index a string', 2)
  
--- 2439,2449 ----
      ], 'E1105:', 2)
  
    v9.CheckDefExecFailure([
!     'g:dd = {"a": 1, 2: 2}',
      'unlet g:dd[0z11]',
      ], 'E1029:', 2)
    v9.CheckDefExecFailure([
!     'g:str = "a string"',
      'unlet g:str[0]',
      ], 'E1148: Cannot index a string', 2)
  
*** ../vim-9.0.0229/src/testdir/test_vim9_disassemble.vim       2022-05-22 
18:25:44.000000000 +0100
--- src/testdir/test_vim9_disassemble.vim       2022-08-20 14:42:58.407382824 
+0100
***************
*** 2106,2112 ****
               '  var aDict = {x: 2}',
               floatDecl,
               '  if ' .. case[0],
!              '    echo 42'
               '  endif',
               'enddef'], 'Xdisassemble')
      source Xdisassemble
--- 2106,2112 ----
               '  var aDict = {x: 2}',
               floatDecl,
               '  if ' .. case[0],
!              '    echo 42',
               '  endif',
               'enddef'], 'Xdisassemble')
      source Xdisassemble
***************
*** 2163,2169 ****
    for case in cases
      writefile(['def TestCase' .. nr .. '()',
               '  if ' .. case[0],
!              '    echo 42'
               '  endif',
               'enddef'], 'Xdisassemble')
      source Xdisassemble
--- 2163,2169 ----
    for case in cases
      writefile(['def TestCase' .. nr .. '()',
               '  if ' .. case[0],
!              '    echo 42',
               '  endif',
               'enddef'], 'Xdisassemble')
      source Xdisassemble
*** ../vim-9.0.0229/src/testdir/test_vim9_func.vim      2022-08-20 
12:07:55.098022792 +0100
--- src/testdir/test_vim9_func.vim      2022-08-20 14:49:14.754016600 +0100
***************
*** 440,461 ****
                     '    echo "no return"',
                     '  else',
                     '    return 0',
!                    '  endif'
                     'enddef'], 'E1027:')
    v9.CheckDefFailure(['def Missing(): number',
                     '  if g:cond',
                     '    return 1',
                     '  else',
                     '    echo "no return"',
!                    '  endif'
                     'enddef'], 'E1027:')
    v9.CheckDefFailure(['def Missing(): number',
                     '  if g:cond',
                     '    return 1',
                     '  else',
                     '    return 2',
!                    '  endif'
!                    '  return 3'
                     'enddef'], 'E1095:')
  enddef
  
--- 440,461 ----
                     '    echo "no return"',
                     '  else',
                     '    return 0',
!                    '  endif',
                     'enddef'], 'E1027:')
    v9.CheckDefFailure(['def Missing(): number',
                     '  if g:cond',
                     '    return 1',
                     '  else',
                     '    echo "no return"',
!                    '  endif',
                     'enddef'], 'E1027:')
    v9.CheckDefFailure(['def Missing(): number',
                     '  if g:cond',
                     '    return 1',
                     '  else',
                     '    return 2',
!                    '  endif',
!                    '  return 3',
                     'enddef'], 'E1095:')
  enddef
  
***************
*** 1496,1502 ****
  
  def Test_lambda_uses_assigned_var()
    v9.CheckDefSuccess([
!         'var x: any = "aaa"'
          'x = filter(["bbb"], (_, v) => v =~ x)'])
  enddef
  
--- 1496,1502 ----
  
  def Test_lambda_uses_assigned_var()
    v9.CheckDefSuccess([
!         'var x: any = "aaa"',
          'x = filter(["bbb"], (_, v) => v =~ x)'])
  enddef
  
*** ../vim-9.0.0229/src/testdir/test_vim9_script.vim    2022-08-18 
13:28:27.724128103 +0100
--- src/testdir/test_vim9_script.vim    2022-08-20 14:48:10.585696442 +0100
***************
*** 3274,3280 ****
  
    v9.CheckScriptSuccess([
        'vim9script',
!       'new'
        'setline(1, ["# define pat", "last"])',
        ':$',
        'dsearch /pat/ #comment',
--- 3274,3280 ----
  
    v9.CheckScriptSuccess([
        'vim9script',
!       'new',
        'setline(1, ["# define pat", "last"])',
        ':$',
        'dsearch /pat/ #comment',
***************
*** 3283,3289 ****
  
    v9.CheckScriptFailure([
        'vim9script',
!       'new'
        'setline(1, ["# define pat", "last"])',
        ':$',
        'dsearch /pat/#comment',
--- 3283,3289 ----
  
    v9.CheckScriptFailure([
        'vim9script',
!       'new',
        'setline(1, ["# define pat", "last"])',
        ':$',
        'dsearch /pat/#comment',
*** ../vim-9.0.0229/src/version.c       2022-08-20 12:07:55.098022792 +0100
--- src/version.c       2022-08-20 14:35:40.175479472 +0100
***************
*** 733,734 ****
--- 733,736 ----
  {   /* Add new patch number below this line */
+ /**/
+     230,
  /**/

-- 
   [SIR LAUNCELOT runs back up the stairs, grabs a rope
   of the wall and swings out over the heads of the CROWD in a
   swashbuckling manner towards a large window.  He stops just short
   of the window and is left swing pathetically back and forth.]
LAUNCELOT: Excuse me ... could somebody give me a push ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220820135200.B72991C0ADA%40moolenaar.net.

Raspunde prin e-mail lui