summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-16 22:29:52 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-16 22:29:52 +0200
commit9939f57b7f1c17a0142ebfe4f9e0b634158593e1 (patch)
tree77a48188a4a88e8bdc7f697ed4f2b06ddf3f6711
parent916911f598718bc76bc6b87ed703d2805fa49c53 (diff)
patch 8.2.1700: Vim9: try/catch causes wrong value to be returnedv8.2.1700
Problem: Vim9: try/catch causes wrong value to be returned. Solution: Reset tcd_return. (closes #6964)
-rw-r--r--src/testdir/test_vim9_script.vim20
-rw-r--r--src/version.c2
-rw-r--r--src/vim9execute.c1
3 files changed, 23 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index c400e82acc..2f1e708f29 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index e77c7957e6..ff5534ff69 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1700,
+/**/
1699,
/**/
1698,
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 7c8f77977c..40d6193ca5 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -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;