Skip to content

Commit 9939f57

Browse files
committed
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Problem: Vim9: try/catch causes wrong value to be returned. Solution: Reset tcd_return. (closes #6964)
1 parent 916911f commit 9939f57

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/testdir/test_vim9_script.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,26 @@ def Test_try_catch_nested()
11691169
assert_equal('finally', g:in_finally)
11701170
enddef
11711171

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+
11721192
def Test_try_catch_match()
11731193
let seq = 'a'
11741194
try

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1700,
753755
/**/
754756
1699,
755757
/**/

src/vim9execute.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,7 @@ call_def_function(
19221922
trycmd->tcd_catch_idx = iptr->isn_arg.try.try_catch;
19231923
trycmd->tcd_finally_idx = iptr->isn_arg.try.try_finally;
19241924
trycmd->tcd_caught = FALSE;
1925+
trycmd->tcd_return = FALSE;
19251926
}
19261927
break;
19271928

0 commit comments

Comments
 (0)