Mirror of the Vim source from https://github.com/vim/vim
リビジョン | 41e118669df33a084f8f0ce470727eebab1b6cb9 (tree) |
---|---|
日時 | 2020-09-19 04:30:04 |
作者 | Bram Moolenaar <Bram@vim....> |
コミッター | Bram Moolenaar |
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Commit: https://github.com/vim/vim/commit/7cbfaa51de7b225effdc79a008c71a5551883c38
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Sep 18 21:25:32 2020 +0200
@@ -1294,6 +1294,20 @@ | ||
1294 | 1294 | GetResult(g:Ref)->assert_equal('sometext') |
1295 | 1295 | enddef |
1296 | 1296 | |
1297 | +def Test_double_closure_fails() | |
1298 | + let lines =<< trim END | |
1299 | + vim9script | |
1300 | + def Func() | |
1301 | + let var = 0 | |
1302 | + for i in range(2) | |
1303 | + timer_start(0, {-> var}) | |
1304 | + endfor | |
1305 | + enddef | |
1306 | + Func() | |
1307 | + END | |
1308 | + CheckScriptFailure(lines, 'Multiple closures not supported yet') | |
1309 | +enddef | |
1310 | + | |
1297 | 1311 | def Test_sort_return_type() |
1298 | 1312 | let res: list<number> |
1299 | 1313 | res = [1, 2, 3]->sort() |
@@ -751,6 +751,8 @@ | ||
751 | 751 | static int included_patches[] = |
752 | 752 | { /* Add new patch number below this line */ |
753 | 753 | /**/ |
754 | + 1706, | |
755 | +/**/ | |
754 | 756 | 1705, |
755 | 757 | /**/ |
756 | 758 | 1704, |
@@ -2676,15 +2676,11 @@ | ||
2676 | 2676 | continue; |
2677 | 2677 | |
2678 | 2678 | func_return: |
2679 | - // Restore previous function. If the frame pointer is zero then there | |
2680 | - // is none and we are done. | |
2679 | + // Restore previous function. If the frame pointer is where we started | |
2680 | + // then there is none and we are done. | |
2681 | 2681 | if (ectx.ec_frame_idx == initial_frame_idx) |
2682 | - { | |
2683 | - if (handle_closure_in_use(&ectx, FALSE) == FAIL) | |
2684 | - // only fails when out of memory | |
2685 | - goto failed; | |
2686 | 2682 | goto done; |
2687 | - } | |
2683 | + | |
2688 | 2684 | if (func_return(&ectx) == FAIL) |
2689 | 2685 | // only fails when out of memory |
2690 | 2686 | goto failed; |
@@ -2703,6 +2699,10 @@ | ||
2703 | 2699 | ret = OK; |
2704 | 2700 | |
2705 | 2701 | failed: |
2702 | + // Also deal with closures when failed, they may already be in use | |
2703 | + // somewhere. | |
2704 | + handle_closure_in_use(&ectx, FALSE); | |
2705 | + | |
2706 | 2706 | // When failed need to unwind the call stack. |
2707 | 2707 | while (ectx.ec_frame_idx != initial_frame_idx) |
2708 | 2708 | func_return(&ectx); |