Mirror of the Vim source from https://github.com/vim/vim
Revision | 36e8e046c33594196e5a0fae806e6bf699462b7a (tree) |
---|---|
Zeit | 2020-09-17 05:30:03 |
Autor | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Commit: https://github.com/vim/vim/commit/9939f57b7f1c17a0142ebfe4f9e0b634158593e1
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 16 22:29:52 2020 +0200
@@ -1169,6 +1169,26 @@ | ||
1169 | 1169 | assert_equal('finally', g:in_finally) |
1170 | 1170 | enddef |
1171 | 1171 | |
1172 | +def TryOne(): number | |
1173 | + try | |
1174 | + return 0 | |
1175 | + catch | |
1176 | + endtry | |
1177 | + return 0 | |
1178 | +enddef | |
1179 | + | |
1180 | +def TryTwo(n: number): string | |
1181 | + try | |
1182 | + let x = {} | |
1183 | + catch | |
1184 | + endtry | |
1185 | + return 'text' | |
1186 | +enddef | |
1187 | + | |
1188 | +def Test_try_catch_twice() | |
1189 | + assert_equal('text', TryOne()->TryTwo()) | |
1190 | +enddef | |
1191 | + | |
1172 | 1192 | def Test_try_catch_match() |
1173 | 1193 | let seq = 'a' |
1174 | 1194 | try |
@@ -751,6 +751,8 @@ | ||
751 | 751 | static int included_patches[] = |
752 | 752 | { /* Add new patch number below this line */ |
753 | 753 | /**/ |
754 | + 1700, | |
755 | +/**/ | |
754 | 756 | 1699, |
755 | 757 | /**/ |
756 | 758 | 1698, |
@@ -1922,6 +1922,7 @@ | ||
1922 | 1922 | trycmd->tcd_catch_idx = iptr->isn_arg.try.try_catch; |
1923 | 1923 | trycmd->tcd_finally_idx = iptr->isn_arg.try.try_finally; |
1924 | 1924 | trycmd->tcd_caught = FALSE; |
1925 | + trycmd->tcd_return = FALSE; | |
1925 | 1926 | } |
1926 | 1927 | break; |
1927 | 1928 |