Patch 8.2.1282
Problem: Vim9: crash when using CheckScriptFailure() in
Test_vim9script_call_fail_decl().
Solution: Do not decrement the def_functions len unless the function was
newly added.
Files: src/vim9compile.c, src/testdir/test_vim9_func.vim
*** ../vim-8.2.1281/src/vim9compile.c 2020-07-23 15:37:59.331156413 +0200
--- src/vim9compile.c 2020-07-23 18:23:18.848666610 +0200
***************
*** 6945,6950 ****
--- 6945,6951 ----
sctx_T save_current_sctx = current_sctx;
int do_estack_push;
int emsg_before = called_emsg;
+ int new_def_function = FALSE;
// When using a function that was compiled before: Free old instructions.
// Otherwise add a new entry in "def_functions".
***************
*** 6954,6961 ****
+ ufunc->uf_dfunc_idx;
delete_def_function_contents(dfunc);
}
! else if (add_def_function(ufunc) == FAIL)
! return FAIL;
ufunc->uf_def_status = UF_COMPILING;
--- 6955,6966 ----
+ ufunc->uf_dfunc_idx;
delete_def_function_contents(dfunc);
}
! else
! {
! if (add_def_function(ufunc) == FAIL)
! return FAIL;
! new_def_function = TRUE;
! }
ufunc->uf_def_status = UF_COMPILING;
***************
*** 7439,7448 ****
delete_instr(((isn_T *)instr->ga_data) + idx);
ga_clear(instr);
! // if using the last entry in the table we might as well remove it
! if (!dfunc->df_deleted
&& ufunc->uf_dfunc_idx == def_functions.ga_len - 1)
--def_functions.ga_len;
ufunc->uf_def_status = UF_NOT_COMPILED;
while (cctx.ctx_scope != NULL)
--- 7444,7457 ----
delete_instr(((isn_T *)instr->ga_data) + idx);
ga_clear(instr);
! // If using the last entry in the table and it was added above, we
! // might as well remove it.
! if (!dfunc->df_deleted && new_def_function
&& ufunc->uf_dfunc_idx == def_functions.ga_len - 1)
+ {
--def_functions.ga_len;
+ ufunc->uf_dfunc_idx = 0;
+ }
ufunc->uf_def_status = UF_NOT_COMPILED;
while (cctx.ctx_scope != NULL)
*** ../vim-8.2.1281/src/testdir/test_vim9_func.vim 2020-07-22 20:16:08.071900823 +0200
--- src/testdir/test_vim9_func.vim 2020-07-23 18:23:32.700594611 +0200
***************
*** 258,264 ****
def Test_call_funcref()
assert_equal(3, g:SomeFunc('abc'))
! assert_fails('NotAFunc()', 'E117:')
assert_fails('g:NotAFunc()', 'E117:')
let lines =<< trim END
--- 258,264 ----
def Test_call_funcref()
assert_equal(3, g:SomeFunc('abc'))
! assert_fails('NotAFunc()', 'E117:') # comment after call
assert_fails('g:NotAFunc()', 'E117:')
let lines =<< trim END
***************
*** 425,433 ****
enddef
defcompile
END
! writefile(lines, 'Xcall_decl.vim')
! assert_fails('source Xcall_decl.vim', 'E1054:')
! delete('Xcall_decl.vim')
enddef
def Test_vim9script_call_fail_type()
--- 425,431 ----
enddef
defcompile
END
! CheckScriptFailure(lines, 'E1054:')
enddef
def Test_vim9script_call_fail_type()
*** ../vim-8.2.1281/src/version.c 2020-07-23 17:16:15.050100601 +0200
--- src/version.c 2020-07-23 17:21:04.464419921 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1282,
/**/
--
hundred-and-one symptoms of being an internet addict:
72. Somebody at IRC just mentioned a way to obtain full motion video without
a PC using a wireless protocol called NTSC, you wonder how you never
heard about it
/// 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 ///