diff src/testdir/test_vim9_func.vim @ 28952:ba083decce5d v8.2.4998

patch 8.2.4998: Vim9: crash when using multiple funcref() Commit: https://github.com/vim/vim/commit/bce69d65dd41020ea1d727337a3baf9e95b40c35 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 22 13:45:52 2022 +0100 patch 8.2.4998: Vim9: crash when using multiple funcref() Problem: Vim9: crash when using multiple funcref(). Solution: Check if varargs type is NULL. (closes https://github.com/vim/vim/issues/10467)
author Bram Moolenaar <Bram@vim.org>
date Sun, 22 May 2022 15:00:02 +0200
parents 338212bba072
children 49d8b54802f3
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -4107,6 +4107,47 @@ func Test_lambda_allocation_failure()
   bw!
 endfunc
 
+def Test_multiple_funcref()
+  # This was using a NULL pointer
+  var lines =<< trim END
+      vim9script
+      def A(F: func, ...args: list<any>): func
+          return funcref(F, args)
+      enddef
+
+      def B(F: func): func
+          return funcref(A, [F])
+      enddef
+
+      def Test(n: number)
+      enddef
+
+      const X = B(Test)
+      X(1)
+  END
+  v9.CheckScriptSuccess(lines)
+
+  # slightly different case
+  lines =<< trim END
+      vim9script
+
+      def A(F: func, ...args: list<any>): any
+          return call(F, args)
+      enddef
+
+      def B(F: func): func
+          return funcref(A, [F])
+      enddef
+
+      def Test(n: number)
+      enddef
+
+      const X = B(Test)
+      X(1)
+  END
+  v9.CheckScriptSuccess(lines)
+enddef
+
 " The following messes up syntax highlight, keep near the end.
 if has('python3')
   def Test_python3_command()