comparison src/testdir/test_vim9_func.vim @ 27591:d91be28bbdbb v8.2.4322

patch 8.2.4322: Vim9: crash when using funcref with closure Commit: https://github.com/vim/vim/commit/7aca5ca6763e50d2c23953b20e30fca7457c9abf Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 7 19:56:43 2022 +0000 patch 8.2.4322: Vim9: crash when using funcref with closure Problem: Vim9: crash when using funcref with closure. Solution: Keep a reference to the funcref that has the outer context. (closes #9716)
author Bram Moolenaar <Bram@vim.org>
date Mon, 07 Feb 2022 21:00:02 +0100
parents ecea41486e8a
children 8c7836f8668d
comparison
equal deleted inserted replaced
27590:cc44ec730954 27591:d91be28bbdbb
3475 assert_equal(1, g:result_one) 3475 assert_equal(1, g:result_one)
3476 assert_equal(2, g:result_two) 3476 assert_equal(2, g:result_two)
3477 unlet g:result_one g:result_two 3477 unlet g:result_one g:result_two
3478 enddef 3478 enddef
3479 3479
3480 def Test_nested_closure_in_dict()
3481 var lines =<< trim END
3482 vim9script
3483 def Func(): dict<any>
3484 var n: number
3485 def Inc(): number
3486 ++n
3487 return n
3488 enddef
3489 return {inc: function(Inc)}
3490 enddef
3491 disas Func
3492 var d = Func()
3493 assert_equal(1, d.inc())
3494 assert_equal(2, d.inc())
3495 END
3496 v9.CheckScriptSuccess(lines)
3497 enddef
3498
3480 def Test_check_func_arg_types() 3499 def Test_check_func_arg_types()
3481 var lines =<< trim END 3500 var lines =<< trim END
3482 vim9script 3501 vim9script
3483 def F1(x: string): string 3502 def F1(x: string): string
3484 return x 3503 return x