Patch 8.2.2743
Problem: Vim9: function state stuck when compiling with ":silent!".
Solution: Check for uf_def_status to be UF_COMPILING.
Files: src/vim9compile.c, src/message.c, src/globals.h,
src/testdir/test_vim9_func.vim
*** ../vim-8.2.2742/src/vim9compile.c 2021-04-10 13:33:44.441064014 +0200
--- src/vim9compile.c 2021-04-10 13:56:04.929765849 +0200
***************
*** 8429,8434 ****
--- 8429,8435 ----
cctx_T cctx;
garray_T *instr;
int did_emsg_before = did_emsg;
+ int did_emsg_silent_before = did_emsg_silent;
int ret = FAIL;
sctx_T save_current_sctx = current_sctx;
int save_estack_compiling = estack_compiling;
***************
*** 8967,8972 ****
--- 8968,8976 ----
generate_instr(&cctx, ISN_RETURN_ZERO);
}
+ // When compiled with ":silent!" and there was an error don't consider the
+ // function compiled.
+ if (emsg_silent == 0 || did_emsg_silent == did_emsg_silent_before)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
***************
*** 8994,9000 ****
ret = OK;
erret:
! if (ret == FAIL)
{
int idx;
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
--- 8998,9004 ----
ret = OK;
erret:
! if (ufunc->uf_def_status == UF_COMPILING)
{
int idx;
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
*** ../vim-8.2.2742/src/message.c 2021-02-15 20:37:58.457374538 +0100
--- src/message.c 2021-04-10 13:54:46.753943208 +0200
***************
*** 685,690 ****
--- 685,693 ----
*/
if (emsg_silent != 0)
{
+ #ifdef FEAT_EVAL
+ ++did_emsg_silent;
+ #endif
if (emsg_noredir == 0)
{
msg_start();
*** ../vim-8.2.2742/src/globals.h 2021-03-21 22:12:31.448826619 +0100
--- src/globals.h 2021-04-10 13:55:11.525887439 +0200
***************
*** 230,235 ****
--- 230,238 ----
EXTERN int did_emsg; // set by emsg() when the message
// is displayed or thrown
#ifdef FEAT_EVAL
+ EXTERN int did_emsg_silent INIT(= 0); // incremented by emsg() when
+ // emsg_silent was set and did_emsg
+ // is not incremented
EXTERN int did_emsg_def; // set by emsg() when emsg_silent
// is set before calling a function
EXTERN int did_emsg_cumul; // cumulative did_emsg, increased
*** ../vim-8.2.2742/src/testdir/test_vim9_func.vim 2021-04-10
13:33:44.441064014 +0200
--- src/testdir/test_vim9_func.vim 2021-04-10 14:02:45.660810325 +0200
***************
*** 2603,2608 ****
--- 2603,2622 ----
# Second call won't try compiling again
assert_fails('call g:Broken()', 'E1091: Function is not compiled: Broken')
+ delfunc g:Broken
+
+ # No error when compiling with :silent!
+ lines =<< trim END
+ def g:Broken()
+ echo 'a' + []
+ enddef
+ silent! defcompile
+ END
+ CheckScriptSuccess(lines)
+
+ # Calling the function won't try compiling again
+ assert_fails('call g:Broken()', 'E1091: Function is not compiled: Broken')
+ delfunc g:Broken
enddef
*** ../vim-8.2.2742/src/version.c 2021-04-10 13:33:44.441064014 +0200
--- src/version.c 2021-04-10 14:00:27.653146290 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2743,
/**/
--
Where do you want to crash today?
/// 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/202104101204.13AC4AH8179256%40masaka.moolenaar.net.