Patch 8.2.1042
Problem: Vim9: cannot put an operator on the next line.
Solution: Require a colon before a range to see if that causes problems.
Files: runtime/doc/vim9.txt, src/vim9compile.c, src/ex_docmd.c,
src/globals.h, src/testdir/test_vim9_script.vim,
src/testdir/test_vim9_expr.vim
*** ../vim-8.2.1041/runtime/doc/vim9.txt 2020-05-24 23:00:06.436196028 +0200
--- runtime/doc/vim9.txt 2020-06-22 22:47:04.604304586 +0200
***************
*** 255,274 ****
arg2
)
! For binary operators iin expressions not in [], {} or () a line break is
! possible AFTER the operators. For example: >
! let text = lead ..
! middle ..
! end
let total = start +
end -
correction
! let result = positive ?
! PosFunc(arg) :
! NegFunc(arg)
!
! Note that "enddef" cannot be used at the start of a continuation line, it ends
! the current function.
It is also possible to split a function header over multiple lines, in between
arguments: >
--- 257,288 ----
arg2
)
! For binary operators in expressions not in [], {} or () a line break is
! possible just before or after the operator. For example: >
! let text = lead
! .. middle
! .. end
let total = start +
end -
correction
! let result = positive
! ? PosFunc(arg)
! : NegFunc(arg)
!
! let result = GetBuilder()
! ->BuilderSetWidth(333)
! ->BuilderSetHeight(777)
! ->BuilderBuild()
!
! < *E1050*
! To make it possible for the operator at the start of the line to be
! recognized, it is required to put a colon before a range. This will adde
! "start" and print: >
! let result = start
! + print
! This will assign "start" and print a line: >
! let result = start
! :+ print
It is also possible to split a function header over multiple lines, in between
arguments: >
***************
*** 277,282 ****
--- 291,299 ----
separator = '-'
): string
+ Note that "enddef" cannot be used at the start of a continuation line, it ends
+ the current function.
+
No curly braces expansion ~
*** ../vim-8.2.1041/src/vim9compile.c 2020-06-22 19:38:59.928402805 +0200
--- src/vim9compile.c 2020-06-22 22:54:37.883243395 +0200
***************
*** 643,649 ****
|| type2 == VAR_ANY)))
{
if (*op == '+')
! emsg(_("E1035: wrong argument type for +"));
else
semsg(_("E1036: %c requires number or float arguments"), *op);
return FAIL;
--- 643,649 ----
|| type2 == VAR_ANY)))
{
if (*op == '+')
! emsg(_("E1051: wrong argument type for +"));
else
semsg(_("E1036: %c requires number or float arguments"), *op);
return FAIL;
***************
*** 6695,6700 ****
--- 6695,6701 ----
{
exarg_T ea;
int starts_with_colon = FALSE;
+ char_u *cmd;
// Bail out on the first error to avoid a flood of errors and report
// the right line number when inside try/catch.
***************
*** 6853,6859 ****
--- 6854,6866 ----
/*
* COMMAND after range
*/
+ cmd = ea.cmd;
ea.cmd = skip_range(ea.cmd, NULL);
+ if (ea.cmd > cmd && !starts_with_colon)
+ {
+ emsg(_(e_colon_required));
+ goto erret;
+ }
p = find_ex_command(&ea, NULL, starts_with_colon ? NULL
: (void *(*)(char_u *, size_t, cctx_T *))lookup_local,
&cctx);
***************
*** 7008,7015 ****
line = compile_mult_expr(p, ea.cmdidx, &cctx);
break;
default:
- // TODO: other commands with an expression argument
// Not recognized, execute with do_cmdline_cmd().
ea.arg = p;
line = compile_exec(line, &ea, &cctx);
--- 7015,7023 ----
line = compile_mult_expr(p, ea.cmdidx, &cctx);
break;
+ // TODO: other commands with an expression argument
+
default:
// Not recognized, execute with do_cmdline_cmd().
ea.arg = p;
line = compile_exec(line, &ea, &cctx);
*** ../vim-8.2.1041/src/ex_docmd.c 2020-06-18 17:28:36.857031469 +0200
--- src/ex_docmd.c 2020-06-22 22:39:08.557326242 +0200
***************
*** 1729,1735 ****
--- 1729,1742 ----
#ifdef FEAT_EVAL
if (current_sctx.sc_version == SCRIPT_VERSION_VIM9 && !starts_with_colon)
+ {
+ if (ea.cmd > cmd)
+ {
+ emsg(_(e_colon_required));
+ goto doend;
+ }
p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL);
+ }
else
#endif
p = find_ex_command(&ea, NULL, NULL, NULL);
***************
*** 3446,3452 ****
* Backslashed delimiters after / or ? will be skipped, and commands will
* not be expanded between /'s and ?'s or after "'".
*
! * Also skip white space and ":" characters.
* Returns the "cmd" pointer advanced to beyond the range.
*/
char_u *
--- 3453,3459 ----
* Backslashed delimiters after / or ? will be skipped, and commands will
* not be expanded between /'s and ?'s or after "'".
*
! * Also skip white space and ":" characters after the range.
* Returns the "cmd" pointer advanced to beyond the range.
*/
char_u *
*** ../vim-8.2.1041/src/globals.h 2020-06-21 20:38:24.488641771 +0200
--- src/globals.h 2020-06-22 22:36:53.613582804 +0200
***************
*** 1790,1795 ****
--- 1790,1796 ----
EXTERN char e_type_req[] INIT(= N_("E1022: type or initialization required"));
EXTERN char e_declare_var[] INIT(= N_("E1016: Cannot declare a %s variable: %s"));
EXTERN char e_declare_env_var[] INIT(= N_("E1016: Cannot declare an environment variable: %s"));
+ EXTERN char e_colon_required[] INIT(= N_("E1050: Colon required before a range"));
#endif
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
EXTERN char e_alloc_color[] INIT(= N_("E254: Cannot allocate color %s"));
*** ../vim-8.2.1041/src/testdir/test_vim9_script.vim 2020-06-21 15:52:55.810451610 +0200
--- src/testdir/test_vim9_script.vim 2020-06-22 22:41:58.248979000 +0200
***************
*** 468,473 ****
--- 468,481 ----
call CheckDefFailure(['const &option'], 'E996:')
endfunc
+ def Test_range_no_colon()
+ call CheckDefFailure(['%s/a/b/'], 'E1050:')
+ call CheckDefFailure(['+ s/a/b/'], 'E1050:')
+ call CheckDefFailure(['- s/a/b/'], 'E1050:')
+ call CheckDefFailure(['. s/a/b/'], 'E1050:')
+ enddef
+
+
def Test_block()
let outer = 1
{
***************
*** 1279,1285 ****
echomsg 'some' 'more' # comment
assert_match('^some more$', Screenline(&lines))
echo 'clear'
! 1messages
assert_match('^some more$', Screenline(&lines))
call CheckDefFailure(['echomsg "xxx"# comment'], 'E488:')
--- 1287,1293 ----
echomsg 'some' 'more' # comment
assert_match('^some more$', Screenline(&lines))
echo 'clear'
! :1messages
assert_match('^some more$', Screenline(&lines))
call CheckDefFailure(['echomsg "xxx"# comment'], 'E488:')
***************
*** 1898,1904 ****
'vim9script',
'new'
'call setline(1, ["# define pat", "last"])',
! '$',
'dsearch /pat/ #comment',
'bwipe!',
])
--- 1906,1912 ----
'vim9script',
'new'
'call setline(1, ["# define pat", "last"])',
! ':$',
'dsearch /pat/ #comment',
'bwipe!',
])
***************
*** 1907,1913 ****
'vim9script',
'new'
'call setline(1, ["# define pat", "last"])',
! '$',
'dsearch /pat/#comment',
'bwipe!',
], 'E488:')
--- 1915,1921 ----
'vim9script',
'new'
'call setline(1, ["# define pat", "last"])',
! ':$',
'dsearch /pat/#comment',
'bwipe!',
], 'E488:')
*** ../vim-8.2.1041/src/testdir/test_vim9_expr.vim 2020-06-21 16:58:09.743688170 +0200
--- src/testdir/test_vim9_expr.vim 2020-06-22 22:54:54.959202553 +0200
***************
*** 585,596 ****
call CheckDefFailure(["let x = '1' ..'2'"], msg)
call CheckDefFailure(["let x = '1'.. '2'"], msg)
! call CheckDefFailure(["let x = 0z1122 + 33"], 'E1035')
! call CheckDefFailure(["let x = 0z1122 + [3]"], 'E1035')
! call CheckDefFailure(["let x = 0z1122 + 'asd'"], 'E1035')
! call CheckDefFailure(["let x = 33 + 0z1122"], 'E1035')
! call CheckDefFailure(["let x = [3] + 0z1122"], 'E1035')
! call CheckDefFailure(["let x = 'asdf' + 0z1122"], 'E1035')
call CheckDefFailure(["let x = 6 + xxx"], 'E1001')
endfunc
--- 585,596 ----
call CheckDefFailure(["let x = '1' ..'2'"], msg)
call CheckDefFailure(["let x = '1'.. '2'"], msg)
! call CheckDefFailure(["let x = 0z1122 + 33"], 'E1051')
! call CheckDefFailure(["let x = 0z1122 + [3]"], 'E1051')
! call CheckDefFailure(["let x = 0z1122 + 'asd'"], 'E1051')
! call CheckDefFailure(["let x = 33 + 0z1122"], 'E1051')
! call CheckDefFailure(["let x = [3] + 0z1122"], 'E1051')
! call CheckDefFailure(["let x = 'asdf' + 0z1122"], 'E1051')
call CheckDefFailure(["let x = 6 + xxx"], 'E1001')
endfunc
*** ../vim-8.2.1041/src/version.c 2020-06-22 22:10:02.769177603 +0200
--- src/version.c 2020-06-22 23:00:37.750375192 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1042,
/**/
--
ARTHUR: No, hang on! Just answer the five questions ...
GALAHAD: Three questions ...
ARTHUR: Three questions ... And we shall watch ... and pray.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///