Patch 8.2.4384
Problem:    Vim9: error message not tested, some code not tested.
Solution:   Add a couple of test cases.  Give an error for a command modifier
            without a command.
Files:      src/errors.h, src/vim9compile.c, src/ex_docmd.c,
            src/testdir/test_vim9_assign.vim, src/testdir/test_vim9_cmd.vim


*** ../vim-8.2.4383/src/errors.h        2022-02-13 13:56:25.798074089 +0000
--- src/errors.h        2022-02-14 20:56:51.148909275 +0000
***************
*** 2791,2797 ****
  // E1080 unused
  EXTERN char e_cannot_unlet_str[]
        INIT(= N_("E1081: Cannot unlet %s"));
! // E1082 unused
  EXTERN char e_missing_backtick[]
        INIT(= N_("E1083: Missing backtick"));
  EXTERN char e_cannot_delete_vim9_script_function_str[]
--- 2791,2798 ----
  // E1080 unused
  EXTERN char e_cannot_unlet_str[]
        INIT(= N_("E1081: Cannot unlet %s"));
! EXTERN char e_command_modifier_without_command[]
!       INIT(= N_("E1082: Command modifier without command"));
  EXTERN char e_missing_backtick[]
        INIT(= N_("E1083: Missing backtick"));
  EXTERN char e_cannot_delete_vim9_script_function_str[]
*** ../vim-8.2.4383/src/vim9compile.c   2022-02-14 19:52:58.351780835 +0000
--- src/vim9compile.c   2022-02-14 21:13:38.807014326 +0000
***************
*** 2761,2773 ****
        cctx.ctx_has_cmdmod = FALSE;
        if (parse_command_modifiers(&ea, &errormsg, &local_cmdmod, FALSE)
                                                                       == FAIL)
!       {
!           if (errormsg != NULL)
!               goto erret;
!           // empty line or comment
!           line = (char_u *)"";
!           continue;
!       }
        generate_cmdmods(&cctx, &local_cmdmod);
        undo_cmdmod(&local_cmdmod);
  
--- 2761,2767 ----
        cctx.ctx_has_cmdmod = FALSE;
        if (parse_command_modifiers(&ea, &errormsg, &local_cmdmod, FALSE)
                                                                       == FAIL)
!           goto erret;
        generate_cmdmods(&cctx, &local_cmdmod);
        undo_cmdmod(&local_cmdmod);
  
*** ../vim-8.2.4383/src/ex_docmd.c      2022-02-11 20:33:11.946342185 +0000
--- src/ex_docmd.c      2022-02-14 21:18:47.430608897 +0000
***************
*** 2784,2789 ****
--- 2784,2790 ----
  {
      char_u  *p;
      int           starts_with_colon = FALSE;
+     int           vim9script = in_vim9script();
  
      CLEAR_POINTER(cmod);
      cmod->cmod_flags = sticky_cmdmod_flags;
***************
*** 2819,2830 ****
--- 2820,2837 ----
                if (eap->nextcmd != NULL)
                    ++eap->nextcmd;
            }
+           if (vim9script && has_cmdmod(cmod, FALSE))
+               *errormsg = _(e_command_modifier_without_command);
            return FAIL;
        }
        if (*eap->cmd == NUL)
        {
            if (!skip_only)
+           {
                ex_pressedreturn = TRUE;
+               if (vim9script && has_cmdmod(cmod, FALSE))
+                   *errormsg = _(e_command_modifier_without_command);
+           }
            return FAIL;
        }
  
***************
*** 2838,2844 ****
        //   verbose[expr] = 2
        // But not:
        //   verbose [a, b] = list
!       if (in_vim9script())
        {
            char_u *s, *n;
  
--- 2845,2851 ----
        //   verbose[expr] = 2
        // But not:
        //   verbose [a, b] = list
!       if (vim9script)
        {
            char_u *s, *n;
  
***************
*** 2915,2921 ****
  #ifdef FEAT_EVAL
                                        // in ":filter #pat# cmd" # does not
                                        // start a comment
!                                    && (!in_vim9script() || VIM_ISWHITE(p[1]))
  #endif
                                     ))
                                break;
--- 2922,2928 ----
  #ifdef FEAT_EVAL
                                        // in ":filter #pat# cmd" # does not
                                        // start a comment
!                                    && (!vim9script || VIM_ISWHITE(p[1]))
  #endif
                                     ))
                                break;
***************
*** 2928,2934 ****
                            }
  #ifdef FEAT_EVAL
                            // Avoid that "filter(arg)" is recognized.
!                           if (in_vim9script() && !VIM_ISWHITE(p[-1]))
                                break;
  #endif
                            if (skip_only)
--- 2935,2941 ----
                            }
  #ifdef FEAT_EVAL
                            // Avoid that "filter(arg)" is recognized.
!                           if (vim9script && !VIM_ISWHITE(p[-1]))
                                break;
  #endif
                            if (skip_only)
*** ../vim-8.2.4383/src/testdir/test_vim9_assign.vim    2022-02-12 
19:52:22.024702251 +0000
--- src/testdir/test_vim9_assign.vim    2022-02-14 20:51:24.485643682 +0000
***************
*** 350,355 ****
--- 350,360 ----
      assert_equal(1, v1)
      assert_equal(2, v2)
  
+     var _x: number
+     [_x, v2] = [6, 7]
+     assert_equal(6, _x)
+     assert_equal(7, v2)
+ 
      var reslist = []
      for text in ['aaa {bbb} ccc', 'ddd {eee} fff']
        var before: string
***************
*** 1481,1486 ****
--- 1486,1492 ----
  
    v9.CheckDefFailure(["var d: dict<number> = {a: '', b: true}"], 'E1012: Type 
mismatch; expected dict<number> but got dict<any>', 1)
    v9.CheckDefFailure(["var d: dict<dict<number>> = {x: {a: '', b: true}}"], 
'E1012: Type mismatch; expected dict<dict<number>> but got dict<dict<any>>', 1)
+   v9.CheckDefFailure(["var d = {x: 1}", "d[1 : 2] = {y: 2}"], 'E1165: Cannot 
use a range with an assignment: d[1 : 2] =', 2)
  enddef
  
  def Test_assign_dict_unknown_type()
*** ../vim-8.2.4383/src/testdir/test_vim9_cmd.vim       2022-02-12 
22:13:02.259074450 +0000
--- src/testdir/test_vim9_cmd.vim       2022-02-14 21:10:33.431239662 +0000
***************
*** 1133,1138 ****
--- 1133,1148 ----
        silent endtry
    END
    v9.CheckDefAndScriptFailure(lines, 'E1176:', 3)
+ 
+   lines =<< trim END
+       leftabove
+   END
+   v9.CheckDefAndScriptFailure(lines, 'E1082:', 1)
+ 
+   lines =<< trim END
+       leftabove # comment
+   END
+   v9.CheckDefAndScriptFailure(lines, 'E1082:', 1)
  enddef
  
  def Test_eval_command()
*** ../vim-8.2.4383/src/version.c       2022-02-14 19:52:58.351780835 +0000
--- src/version.c       2022-02-14 20:44:16.754766336 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4384,
  /**/

-- 
Don't believe everything you hear or anything you say.

 /// 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/20220214212008.073D21C0DFF%40moolenaar.net.

Raspunde prin e-mail lui