]> granicus.if.org Git - vim/commitdiff
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned v8.2.1700
authorBram Moolenaar <Bram@vim.org>
Wed, 16 Sep 2020 20:29:52 +0000 (22:29 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 16 Sep 2020 20:29:52 +0000 (22:29 +0200)
Problem:    Vim9: try/catch causes wrong value to be returned.
Solution:   Reset tcd_return. (closes #6964)

src/testdir/test_vim9_script.vim
src/version.c
src/vim9execute.c

index c400e82acc993512dd5b2014eb39376daacaf4a9..2f1e708f29847e0cae6e51e36e0a545e1652f08e 100644 (file)
@@ -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
index e77c7957e64d08dccd846ac651f35f3fcc02f72f..ff5534ff69a674942fa49178831fe2fa4fe6b141 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1700,
 /**/
     1699,
 /**/
index 7c8f77977c208513caa26860fca6a6a916a50971..40d6193ca58e36b97d7ca83260075d8affa9aa74 100644 (file)
@@ -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;