Patch 8.2.4514
Problem: Vim9: some flow commands can be shortened.
Solution: Also require using the full name for ":return", ":enddef",
":continue", ":export" and ":import".
Files: src/ex_cmds.h, src/ex_docmd.c, src/errors.h, src/userfunc.c,
src/testdir/test_vim9_script.vim
*** ../vim-8.2.4513/src/ex_cmds.h 2022-03-05 12:56:39.908475507 +0000
--- src/ex_cmds.h 2022-03-05 19:45:57.186220865 +0000
***************
*** 408,414 ****
EX_BANG|EX_TRLBAR|EX_WORD1|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_continue, "continue", ex_continue,
! EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_confirm, "confirm", ex_wrongmodifier,
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_CMDWIN|EX_LOCK_OK,
--- 408,414 ----
EX_BANG|EX_TRLBAR|EX_WORD1|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_continue, "continue", ex_continue,
! EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_confirm, "confirm", ex_wrongmodifier,
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_CMDWIN|EX_LOCK_OK,
***************
*** 567,573 ****
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_enddef, "enddef", ex_endfunction,
! EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_endenum, "endenum", ex_ni,
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
--- 567,573 ----
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_enddef, "enddef", ex_endfunction,
! EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_endenum, "endenum", ex_ni,
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
***************
*** 603,609 ****
EX_RANGE|EX_WHOLEFOLD|EX_BANG|EX_FILE1|EX_ARGOPT|EX_DFLALL|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_LINES),
EXCMD(CMD_export, "export", ex_export,
! EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_exusage, "exusage", ex_exusage,
EX_TRLBAR,
--- 603,609 ----
EX_RANGE|EX_WHOLEFOLD|EX_BANG|EX_FILE1|EX_ARGOPT|EX_DFLALL|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_LINES),
EXCMD(CMD_export, "export", ex_export,
! EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_exusage, "exusage", ex_exusage,
EX_TRLBAR,
***************
*** 732,738 ****
EX_RANGE|EX_ZEROR|EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,
ADDR_OTHER),
EXCMD(CMD_import, "import", ex_import,
! EX_EXTRA|EX_NOTRLCOM|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_inoremap, "inoremap", ex_map,
EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,
--- 732,738 ----
EX_RANGE|EX_ZEROR|EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,
ADDR_OTHER),
EXCMD(CMD_import, "import", ex_import,
! EX_EXTRA|EX_NOTRLCOM|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_inoremap, "inoremap", ex_map,
EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,
***************
*** 1281,1287 ****
EX_TRLBAR|EX_RANGE|EX_WHOLEFOLD|EX_DFLALL|EX_BANG|EX_WORD1|EX_CMDWIN|EX_LOCK_OK|EX_MODIFY,
ADDR_LINES),
EXCMD(CMD_return, "return", ex_return,
! EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_rewind, "rewind", ex_rewind,
EX_EXTRA|EX_BANG|EX_CMDARG|EX_ARGOPT|EX_TRLBAR,
--- 1281,1287 ----
EX_TRLBAR|EX_RANGE|EX_WHOLEFOLD|EX_DFLALL|EX_BANG|EX_WORD1|EX_CMDWIN|EX_LOCK_OK|EX_MODIFY,
ADDR_LINES),
EXCMD(CMD_return, "return", ex_return,
! EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
EXCMD(CMD_rewind, "rewind", ex_rewind,
EX_EXTRA|EX_BANG|EX_CMDARG|EX_ARGOPT|EX_TRLBAR,
*** ../vim-8.2.4513/src/ex_docmd.c 2022-03-05 12:56:39.908475507 +0000
--- src/ex_docmd.c 2022-03-05 20:05:05.919063672 +0000
***************
*** 3753,3768 ****
// :Print and :mode are not supported in Vim9 script.
// Some commands cannot be shortened in Vim9 script.
- // ":continue" needs at least ":cont", since ":con" looks weird.
if (vim9 && eap->cmdidx != CMD_SIZE)
{
if (eap->cmdidx == CMD_mode || eap->cmdidx == CMD_Print)
eap->cmdidx = CMD_SIZE;
! else if (((cmdnames[eap->cmdidx].cmd_argt & EX_WHOLE)
&& len < (int)STRLEN(cmdnames[eap->cmdidx].cmd_name))
- || (eap->cmdidx == CMD_continue && len < 4))
{
! semsg(_(e_command_cannot_be_shortened), eap->cmd);
eap->cmdidx = CMD_SIZE;
}
}
--- 3753,3766 ----
// :Print and :mode are not supported in Vim9 script.
// Some commands cannot be shortened in Vim9 script.
if (vim9 && eap->cmdidx != CMD_SIZE)
{
if (eap->cmdidx == CMD_mode || eap->cmdidx == CMD_Print)
eap->cmdidx = CMD_SIZE;
! else if ((cmdnames[eap->cmdidx].cmd_argt & EX_WHOLE)
&& len < (int)STRLEN(cmdnames[eap->cmdidx].cmd_name))
{
! semsg(_(e_command_cannot_be_shortened_str), eap->cmd);
eap->cmdidx = CMD_SIZE;
}
}
*** ../vim-8.2.4513/src/errors.h 2022-03-05 12:56:39.908475507 +0000
--- src/errors.h 2022-03-05 20:05:56.494843108 +0000
***************
*** 2761,2767 ****
#endif
EXTERN char e_yank_register_changed_while_using_it[]
INIT(= N_("E1064: Yank register changed while using it"));
! EXTERN char e_command_cannot_be_shortened[]
INIT(= N_("E1065: Command cannot be shortened: %s"));
#ifdef FEAT_EVAL
EXTERN char e_cannot_declare_a_register_str[]
--- 2761,2767 ----
#endif
EXTERN char e_yank_register_changed_while_using_it[]
INIT(= N_("E1064: Yank register changed while using it"));
! EXTERN char e_command_cannot_be_shortened_str[]
INIT(= N_("E1065: Command cannot be shortened: %s"));
#ifdef FEAT_EVAL
EXTERN char e_cannot_declare_a_register_str[]
*** ../vim-8.2.4513/src/userfunc.c 2022-02-25 21:35:14.432102316 +0000
--- src/userfunc.c 2022-03-05 20:05:32.378947043 +0000
***************
*** 821,826 ****
--- 821,827 ----
{
int c;
char_u *end;
+ char_u *cmd;
// skip ':' and blanks
for (p = theline; VIM_ISWHITE(*p) || *p == ':'; ++p)
***************
*** 828,839 ****
--- 829,844 ----
// Check for "endfunction", "enddef" or "}".
// When a ":" follows it must be a dict key; "enddef: value,"
+ cmd = p;
if (nesting_inline[nesting]
? *p == '}'
: (checkforcmd(&p, nesting_def[nesting]
? "enddef" : "endfunction", 4)
&& *p != ':'))
{
+ if (!nesting_inline[nesting] && nesting_def[nesting]
+ && p < cmd + 6)
+ semsg(_(e_command_cannot_be_shortened_str), "enddef");
if (nesting-- == 0)
{
char_u *nextcmd = NULL;
*** ../vim-8.2.4513/src/testdir/test_vim9_script.vim 2022-03-05
12:56:39.912475510 +0000
--- src/testdir/test_vim9_script.vim 2022-03-05 19:59:31.560809881 +0000
***************
*** 3381,3386 ****
--- 3381,3390 ----
'cat',
'catc',
'con',
+ 'cont',
+ 'conti',
+ 'contin',
+ 'continu',
'el',
'els',
'elsei',
***************
*** 3391,3398 ****
--- 3395,3410 ----
'endw',
'endt',
'endtr',
+ 'exp',
+ 'expo',
+ 'expor',
'fina',
'finall',
+ 'imp',
+ 'impo',
+ 'impor',
+ 'retu',
+ 'retur',
'th',
'thr',
'thro',
***************
*** 3403,3408 ****
--- 3415,3433 ----
for name in names
v9.CheckDefAndScriptFailure([name .. ' '], 'E1065:')
endfor
+
+ var lines =<< trim END
+ vim9script
+ def SomeFunc()
+ endd
+ END
+ v9.CheckScriptFailure(lines, 'E1065:')
+ lines =<< trim END
+ vim9script
+ def SomeFunc()
+ endde
+ END
+ v9.CheckScriptFailure(lines, 'E1065:')
enddef
def Test_unset_any_variable()
*** ../vim-8.2.4513/src/version.c 2022-03-05 17:00:28.757376113 +0000
--- src/version.c 2022-03-05 20:08:27.434237016 +0000
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 4514,
/**/
--
If Microsoft would build a car...
... Occasionally, executing a maneuver such as a left turn
would cause your car to shut down and refuse to restart, in
which case you would have to reinstall the engine.
/// 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/20220305202606.63CAA1C16E8%40moolenaar.net.