Skip to content

Commit

Permalink
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Browse files Browse the repository at this point in the history
Problem:    Vim9: try/catch causes wrong value to be returned.
Solution:   Reset tcd_return. (closes #6964)
  • Loading branch information
brammool committed Sep 16, 2020
1 parent 916911f commit 9939f57
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/testdir/test_vim9_script.vim
Expand Up @@ -1169,6 +1169,26 @@ def Test_try_catch_nested()
assert_equal('finally', g:in_finally)
enddef

def TryOne(): number
try
return 0
catch
endtry
return 0
enddef

def TryTwo(n: number): string
try
let x = {}
catch
endtry
return 'text'
enddef

def Test_try_catch_twice()
assert_equal('text', TryOne()->TryTwo())
enddef

def Test_try_catch_match()
let seq = 'a'
try
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1700,
/**/
1699,
/**/
Expand Down
1 change: 1 addition & 0 deletions src/vim9execute.c
Expand Up @@ -1922,6 +1922,7 @@ call_def_function(
trycmd->tcd_catch_idx = iptr->isn_arg.try.try_catch;
trycmd->tcd_finally_idx = iptr->isn_arg.try.try_finally;
trycmd->tcd_caught = FALSE;
trycmd->tcd_return = FALSE;
}
break;

Expand Down

0 comments on commit 9939f57

Please sign in to comment.