comparison src/testdir/test_vim9_func.vim @ 23285:112fa621b127 v8.2.2188

patch 8.2.2188: Vim9: crash when calling global function from :def function Commit: https://github.com/vim/vim/commit/cd45ed03bfdd7fac53d562ad402df74bd26e7754 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Dec 22 17:35:54 2020 +0100 patch 8.2.2188: Vim9: crash when calling global function from :def function Problem: Vim9: crash when calling global function from :def function. Solution: Set the outer context. Define the partial for the context on the original function. Use a refcount to keep track of which ufunc is using a dfunc. (closes #7525)
author Bram Moolenaar <Bram@vim.org>
date Tue, 22 Dec 2020 17:45:03 +0100
parents 5b4db8035d1d
children ac701146c708
comparison
equal deleted inserted replaced
23284:3d54c7fa353c 23285:112fa621b127
297 defcompile 297 defcompile
298 Outer() 298 Outer()
299 Outer() 299 Outer()
300 END 300 END
301 CheckScriptFailure(lines, "E122:") 301 CheckScriptFailure(lines, "E122:")
302 delfunc g:Inner
302 303
303 lines =<< trim END 304 lines =<< trim END
304 vim9script 305 vim9script
305 def Func() 306 def Func()
306 echo 'script' 307 echo 'script'
1563 var expected = repeat(['ccc', 'bbb', 'aaa'], 3) 1564 var expected = repeat(['ccc', 'bbb', 'aaa'], 3)
1564 assert_equal(expected, getline(1, 9)) 1565 assert_equal(expected, getline(1, 9))
1565 bwipe! 1566 bwipe!
1566 enddef 1567 enddef
1567 1568
1569 def Test_global_closure_called_directly()
1570 var lines =<< trim END
1571 vim9script
1572 def Outer()
1573 var x = 1
1574 def g:Inner()
1575 var y = x
1576 x += 1
1577 assert_equal(1, y)
1578 enddef
1579 g:Inner()
1580 assert_equal(2, x)
1581 enddef
1582 Outer()
1583 END
1584 CheckScriptSuccess(lines)
1585 delfunc g:Inner
1586 enddef
1587
1568 def Test_failure_in_called_function() 1588 def Test_failure_in_called_function()
1569 # this was using the frame index as the return value 1589 # this was using the frame index as the return value
1570 var lines =<< trim END 1590 var lines =<< trim END
1571 vim9script 1591 vim9script
1572 au TerminalWinOpen * eval [][0] 1592 au TerminalWinOpen * eval [][0]