Patch 8.2.2926
Problem:    Vim9: no good error for using :legacy in a :def function.
Solution:   Give an explicit error where :legacy is not working.
            (closes #8309)
Files:      src/vim9compile.c, src/errors.h, src/testdir/test_vim9_func.vim


*** ../vim-8.2.2925/src/vim9compile.c   2021-05-28 21:06:04.624687355 +0200
--- src/vim9compile.c   2021-06-02 16:45:59.635538485 +0200
***************
*** 9222,9227 ****
--- 9222,9248 ----
        {
            char_u *start = ea.cmd;
  
+           switch (ea.cmdidx)
+           {
+               case CMD_if:
+               case CMD_elseif:
+               case CMD_else:
+               case CMD_endif:
+               case CMD_for:
+               case CMD_endfor:
+               case CMD_continue:
+               case CMD_break:
+               case CMD_while:
+               case CMD_endwhile:
+               case CMD_try:
+               case CMD_catch:
+               case CMD_finally:
+               case CMD_endtry:
+                       semsg(_(e_cannot_use_legacy_with_command_str), ea.cmd);
+                       goto erret;
+               default: break;
+           }
+ 
            // ":legacy return expr" needs to be handled differently.
            if (checkforcmd(&start, "return", 4))
                ea.cmdidx = CMD_return;
*** ../vim-8.2.2925/src/errors.h        2021-05-30 13:53:43.220969186 +0200
--- src/errors.h        2021-06-02 16:34:06.449627454 +0200
***************
*** 417,419 ****
--- 417,421 ----
        INIT(= N_("E1187: Failed to source defaults.vim"));
  EXTERN char e_cannot_open_terminal_from_command_line_window[]
        INIT(= N_("E1188: Cannot open a terminal from the command line 
window"));
+ EXTERN char e_cannot_use_legacy_with_command_str[]
+       INIT(= N_("E1189: Cannot use :legacy with this command: %s"));
*** ../vim-8.2.2925/src/testdir/test_vim9_func.vim      2021-05-25 
20:13:56.316778428 +0200
--- src/testdir/test_vim9_func.vim      2021-06-02 16:45:58.223542220 +0200
***************
*** 2207,2212 ****
--- 2207,2221 ----
    CheckScriptSuccess(lines)
  enddef
  
+ def Test_legacy_errors()
+   for cmd in ['if', 'elseif', 'else', 'endif',
+               'for', 'endfor', 'continue', 'break',
+               'while', 'endwhile',
+               'try', 'catch', 'finally', 'endtry']
+     CheckDefFailure(['legacy ' .. cmd .. ' expr'], 'E1189:')
+   endfor
+ enddef
+ 
  def DoFilterThis(a: string): list<string>
    # closure nested inside another closure using argument
    var Filter = (l) => filter(l, (_, v) => stridx(v, a) == 0)
*** ../vim-8.2.2925/src/version.c       2021-06-02 15:28:11.651513682 +0200
--- src/version.c       2021-06-02 16:38:03.260876326 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2926,
  /**/

-- 
Men may not be seen publicly in any kind of strapless gown.
                [real standing law in Florida, United States of America]

 /// 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/202106021448.152EmSHe2598153%40masaka.moolenaar.net.

Raspunde prin e-mail lui