Patch 8.2.1706

5 views
Skip to first unread message

Bram Moolenaar

unread,
Sep 18, 2020, 3:26:13 PM9/18/20
to vim...@googlegroups.com

Patch 8.2.1706
Problem: Vim9: crash after running into the "Multiple closures" error.
Solution: When a function fails still update any closures. (closes #6973)
Files: src/vim9execute.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.1705/src/vim9execute.c 2020-09-17 21:28:59.939951846 +0200
--- src/vim9execute.c 2020-09-18 21:23:08.323468431 +0200
***************
*** 2676,2690 ****
continue;

func_return:
! // Restore previous function. If the frame pointer is zero then there
! // is none and we are done.
if (ectx.ec_frame_idx == initial_frame_idx)
- {
- if (handle_closure_in_use(&ectx, FALSE) == FAIL)
- // only fails when out of memory
- goto failed;
goto done;
! }
if (func_return(&ectx) == FAIL)
// only fails when out of memory
goto failed;
--- 2676,2686 ----
continue;

func_return:
! // Restore previous function. If the frame pointer is where we started
! // then there is none and we are done.
if (ectx.ec_frame_idx == initial_frame_idx)
goto done;
!
if (func_return(&ectx) == FAIL)
// only fails when out of memory
goto failed;
***************
*** 2703,2708 ****
--- 2699,2708 ----
ret = OK;

failed:
+ // Also deal with closures when failed, they may already be in use
+ // somewhere.
+ handle_closure_in_use(&ectx, FALSE);
+
// When failed need to unwind the call stack.
while (ectx.ec_frame_idx != initial_frame_idx)
func_return(&ectx);
*** ../vim-8.2.1705/src/testdir/test_vim9_func.vim 2020-09-16 23:23:33.026882158 +0200
--- src/testdir/test_vim9_func.vim 2020-09-18 21:22:45.115547868 +0200
***************
*** 1294,1299 ****
--- 1294,1313 ----
GetResult(g:Ref)->assert_equal('sometext')
enddef

+ def Test_double_closure_fails()
+ let lines =<< trim END
+ vim9script
+ def Func()
+ let var = 0
+ for i in range(2)
+ timer_start(0, {-> var})
+ endfor
+ enddef
+ Func()
+ END
+ CheckScriptFailure(lines, 'Multiple closures not supported yet')
+ enddef
+
def Test_sort_return_type()
let res: list<number>
res = [1, 2, 3]->sort()
*** ../vim-8.2.1705/src/version.c 2020-09-18 19:40:41.670037639 +0200
--- src/version.c 2020-09-18 21:24:32.943178148 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1706,
/**/

--
SOLDIER: Where did you get the coconuts?
ARTHUR: Through ... We found them.
SOLDIER: Found them? In Mercea. The coconut's tropical!
"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 ///
Reply all
Reply to author
Forward
0 new messages