comparison src/testdir/test_vim9_func.vim @ 23925:e979bf909fd8 v8.2.2505

patch 8.2.2505: Vim9: crash after defining function with invalid return type Commit: https://github.com/vim/vim/commit/31842cd0772b557eb9584a13740430db29de8a51 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 12 22:10:21 2021 +0100 patch 8.2.2505: Vim9: crash after defining function with invalid return type Problem: Vim9: crash after defining function with invalid return type. Solution: Clear function growarrays. Fix memory leak.
author Bram Moolenaar <Bram@vim.org>
date Fri, 12 Feb 2021 22:15:03 +0100
parents be36288235af
children 949238ccbd50
comparison
equal deleted inserted replaced
23924:2f0d80c68af1 23925:e979bf909fd8
252 return xxx 252 return xxx
253 enddef 253 enddef
254 defcompile 254 defcompile
255 END 255 END
256 CheckScriptFailure(lines, 'E1010:', 2) 256 CheckScriptFailure(lines, 'E1010:', 2)
257
258 lines =<< trim END
259 vim9script
260 def Test(Fun: func(number): number): list<number>
261 return map([1, 2, 3], (_, i) => Fun(i))
262 enddef
263 defcompile
264 def Inc(nr: number): nr
265 return nr + 2
266 enddef
267 echo Test(Inc)
268 END
269 # doing this twice was leaking memory
270 CheckScriptFailure(lines, 'E1010:')
271 CheckScriptFailure(lines, 'E1010:')
257 enddef 272 enddef
258 273
259 func Increment() 274 func Increment()
260 let g:counter += 1 275 let g:counter += 1
261 endfunc 276 endfunc