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()
continue;
func_return:
- // Restore previous function. If the frame pointer is zero then there
- // is none and we are done.
+ // 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)
- {
- 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;
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);