Patch 8.2.1859

4 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 17, 2020, 4:04:46 PM10/17/20
to vim...@googlegroups.com

Patch 8.2.1859
Problem: Vim9: crash in unpack assignment.
Solution: Make sure an error message is turned into an exception.
(closes #7159)
Files: src/vim9execute.c, src/testdir/test_vim9_assign.vim,
src/testdir/test_vim9_script.vim


*** ../vim-8.2.1858/src/vim9execute.c 2020-10-16 23:16:43.459258200 +0200
--- src/vim9execute.c 2020-10-17 22:02:18.131155533 +0200
***************
*** 830,835 ****
--- 830,837 ----
int breakcheck_count = 0;
int called_emsg_before = called_emsg;
int save_suppress_errthrow = suppress_errthrow;
+ msglist_T **saved_msg_list = NULL;
+ msglist_T *private_msg_list = NULL;

// Get pointer to item in the stack.
#define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
***************
*** 982,987 ****
--- 984,994 ----
current_sctx = ufunc->uf_script_ctx;
current_sctx.sc_version = SCRIPT_VERSION_VIM9;

+ // Use a specific location for storing error messages to be converted to an
+ // exception.
+ saved_msg_list = msg_list;
+ msg_list = &private_msg_list;
+
// Do turn errors into exceptions.
suppress_errthrow = FALSE;

***************
*** 2819,2824 ****
--- 2826,2844 ----
estack_pop();
current_sctx = save_current_sctx;

+ if (*msg_list != NULL && saved_msg_list != NULL)
+ {
+ msglist_T **plist = saved_msg_list;
+
+ // Append entries from the current msg_list (uncaught exceptions) to
+ // the saved msg_list.
+ while (*plist != NULL)
+ plist = &(*plist)->next;
+
+ *plist = *msg_list;
+ }
+ msg_list = saved_msg_list;
+
failed_early:
// Free all local variables, but not arguments.
for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx)
*** ../vim-8.2.1858/src/testdir/test_vim9_assign.vim 2020-10-17 18:51:48.501219339 +0200
--- src/testdir/test_vim9_assign.vim 2020-10-17 21:39:28.063281783 +0200
***************
*** 622,627 ****
--- 622,630 ----
CheckDefExecFailure(['var x: number',
'var y: number',
'[x, y] = [1]'], 'E1093:')
+ CheckDefExecFailure(['var x: string',
+ 'var y: string',
+ '[x, y] = ["x"]'], 'E1093:')
CheckDefExecFailure(['var x: number',
'var y: number',
'var z: list<number>',
*** ../vim-8.2.1858/src/testdir/test_vim9_script.vim 2020-10-16 20:25:19.357530433 +0200
--- src/testdir/test_vim9_script.vim 2020-10-17 22:01:08.067368318 +0200
***************
*** 620,625 ****
--- 620,626 ----

lines =<< trim END
vim9script
+ @r = ''
def Func()
throw @r
enddef
***************
*** 2818,2823 ****
--- 2819,2845 ----
CheckScriptFailure(lines, 'E121:', 6)
enddef

+ def Test_catch_exception_in_callback()
+ var lines =<< trim END
+ vim9script
+ def Callback(...l: any)
+ try
+ var x: string
+ var y: string
+ # this error should be caught with CHECKLEN
+ [x, y] = ['']
+ catch
+ g:caught = 'yes'
+ endtry
+ enddef
+ popup_menu('popup', #{callback: Callback})
+ feedkeys("\r", 'xt')
+ END
+ CheckScriptSuccess(lines)
+
+ unlet g:caught
+ enddef
+
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new
*** ../vim-8.2.1858/src/version.c 2020-10-17 19:29:47.526935795 +0200
--- src/version.c 2020-10-17 19:57:52.686619011 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1859,
/**/

--
From "know your smileys":
%-) After staring at screen for 15 hours

/// 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 ///
Reply all
Reply to author
Forward
0 new messages