Patch 8.2.0561
Problem: Vim9: cannot split function call in multiple lines.
Solution: Find more arguments in following lines.
Files: runtime/doc/vim9.txt, src/vim9compile.c,
src/testdir/test_vim9_script.vim
*** ../vim-8.2.0560/runtime/doc/vim9.txt 2020-04-12 16:38:54.775938935 +0200
--- runtime/doc/vim9.txt 2020-04-12 20:09:13.069383698 +0200
***************
*** 184,189 ****
--- 184,202 ----
'one',
'two',
]
+ And when a dict spans multiple lines: >
+ let mydict = #{
+ one: 1,
+ two: 2,
+ }
+ Function call: >
+ let result = Func(
+ arg1,
+ arg2
+ )
+
+ 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.0560/src/vim9compile.c 2020-04-12 19:37:13.526297236 +0200
--- src/vim9compile.c 2020-04-12 20:15:04.880466965 +0200
***************
*** 2049,2054 ****
--- 2049,2075 ----
}
/*
+ * Get the next line of the function from "cctx".
+ * Returns NULL when at the end.
+ */
+ static char_u *
+ next_line_from_context(cctx_T *cctx)
+ {
+ char_u *line = NULL;
+
+ do
+ {
+ ++cctx->ctx_lnum;
+ if (cctx->ctx_lnum >= cctx->ctx_ufunc->uf_lines.ga_len)
+ break;
+ line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum];
+ SOURCING_LNUM = cctx->ctx_ufunc->uf_script_ctx.sc_lnum
+ + cctx->ctx_lnum + 1;
+ } while (line == NULL);
+ return line;
+ }
+
+ /*
* Generate an instruction to load script-local variable "name", without the
* leading "s:".
* Also finds imported variables.
***************
*** 2284,2291 ****
{
char_u *p = *arg;
! while (*p != NUL && *p != ')')
{
if (compile_expr1(&p, cctx) == FAIL)
return FAIL;
++*argcount;
--- 2305,2325 ----
{
char_u *p = *arg;
! for (;;)
{
+ if (*p == NUL)
+ {
+ p = next_line_from_context(cctx);
+ if (p == NULL)
+ break;
+ p = skipwhite(p);
+ }
+ if (*p == ')')
+ {
+ *arg = p + 1;
+ return OK;
+ }
+
if (compile_expr1(&p, cctx) == FAIL)
return FAIL;
++*argcount;
***************
*** 2298,2316 ****
if (*p == ',')
{
++p;
! if (!VIM_ISWHITE(*p))
semsg(_(e_white_after), ",");
}
p = skipwhite(p);
}
! p = skipwhite(p);
! if (*p != ')')
! {
! emsg(_(e_missing_close));
! return FAIL;
! }
! *arg = p + 1;
! return OK;
}
/*
--- 2332,2345 ----
if (*p == ',')
{
++p;
! if (*p != NUL && !VIM_ISWHITE(*p))
semsg(_(e_white_after), ",");
}
p = skipwhite(p);
}
!
! emsg(_(e_missing_close));
! return FAIL;
}
/*
***************
*** 2535,2561 ****
}
/*
- * Get the next line of the function from "cctx".
- * Returns NULL when at the end.
- */
- static char_u *
- next_line_from_context(cctx_T *cctx)
- {
- char_u *line = NULL;
-
- do
- {
- ++cctx->ctx_lnum;
- if (cctx->ctx_lnum >= cctx->ctx_ufunc->uf_lines.ga_len)
- break;
- line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum];
- SOURCING_LNUM = cctx->ctx_ufunc->uf_script_ctx.sc_lnum
- + cctx->ctx_lnum + 1;
- } while (line == NULL);
- return line;
- }
-
- /*
* parse a list: [expr, expr]
* "*arg" points to the '['.
*/
--- 2564,2569 ----
*** ../vim-8.2.0560/src/testdir/test_vim9_script.vim 2020-04-12 16:38:54.775938935 +0200
--- src/testdir/test_vim9_script.vim 2020-04-12 20:17:41.980056201 +0200
***************
*** 636,651 ****
def Test_import_absolute()
let import_lines = [
! \ 'vim9script',
! \ 'import exported from "' .. escape(getcwd(), '\') .. '/Xexport_abs.vim"',
! \ 'def UseExported()',
! \ ' g:imported_abs = exported',
! \ ' exported = 8888',
! \ ' g:imported_after = exported',
! \ 'enddef',
! \ 'UseExported()',
! \ 'g:import_disassembled = execute("disass UseExported")',
! \ ]
writefile(import_lines, 'Ximport_abs.vim')
writefile(s:export_script_lines, 'Xexport_abs.vim')
--- 636,651 ----
def Test_import_absolute()
let import_lines = [
! 'vim9script',
! 'import exported from "' .. escape(getcwd(), '\') .. '/Xexport_abs.vim"',
! 'def UseExported()',
! ' g:imported_abs = exported',
! ' exported = 8888',
! ' g:imported_after = exported',
! 'enddef',
! 'UseExported()',
! 'g:import_disassembled = execute("disass UseExported")',
! ]
writefile(import_lines, 'Ximport_abs.vim')
writefile(s:export_script_lines, 'Xexport_abs.vim')
***************
*** 661,668 ****
\ .. '3 STORESCRIPT exported in .*Xexport_abs.vim.*'
\ .. 'g:imported_after = exported.*'
\ .. '4 LOADSCRIPT exported from .*Xexport_abs.vim.*'
! \ .. '5 STOREG g:imported_after.*'
! \, g:import_disassembled)
unlet g:imported_abs
unlet g:import_disassembled
--- 661,668 ----
\ .. '3 STORESCRIPT exported in .*Xexport_abs.vim.*'
\ .. 'g:imported_after = exported.*'
\ .. '4 LOADSCRIPT exported from .*Xexport_abs.vim.*'
! \ .. '5 STOREG g:imported_after.*',
! g:import_disassembled)
unlet g:imported_abs
unlet g:import_disassembled
***************
*** 672,681 ****
def Test_import_rtp()
let import_lines = [
! \ 'vim9script',
! \ 'import exported from "Xexport_rtp.vim"',
! \ 'g:imported_rtp = exported',
! \ ]
writefile(import_lines, 'Ximport_rtp.vim')
mkdir('import')
writefile(s:export_script_lines, 'import/Xexport_rtp.vim')
--- 672,681 ----
def Test_import_rtp()
let import_lines = [
! 'vim9script',
! 'import exported from "Xexport_rtp.vim"',
! 'g:imported_rtp = exported',
! ]
writefile(import_lines, 'Ximport_rtp.vim')
mkdir('import')
writefile(s:export_script_lines, 'import/Xexport_rtp.vim')
***************
*** 988,993 ****
--- 988,998 ----
three: 3 " comment
}
assert_equal(#{one: 1, two: 2, three: 3}, mydict)
+
+ assert_equal(
+ ['one', 'two', 'three'],
+ split('one two three')
+ )
enddef
" Keep this last, it messes up highlighting.
*** ../vim-8.2.0560/src/version.c 2020-04-12 20:01:00.310654732 +0200
--- src/version.c 2020-04-12 20:07:43.933615050 +0200
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 561,
/**/
--
Mynd you, m00se bites Kan be pretty nasti ...
"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 ///