Mercurial > vim
comparison src/testdir/test_lua.vim @ 16028:8ad2cda3757d v8.1.1019
patch 8.1.1019: Lua: may garbage collect function reference in use
commit https://github.com/vim/vim/commit/4eefe47ea4b6bf958617e924f52bc7a409cfb0ed
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Mar 19 21:59:19 2019 +0100
patch 8.1.1019: Lua: may garbage collect function reference in use
Problem: Lua: may garbage collect function reference in use.
Solution: Keep the function name instead of the typeval. Make luaV_setref()
handle funcref objects. (Ozaki Kiichi, closes #4127)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 19 Mar 2019 22:00:07 +0100 |
parents | 725255793949 |
children | a2f0e93a5857 |
comparison
equal
deleted
inserted
replaced
16027:d9cbab38f941 | 16028:8ad2cda3757d |
---|---|
447 let mydict = {'data': l} | 447 let mydict = {'data': l} |
448 lua d = vim.eval"mydict" | 448 lua d = vim.eval"mydict" |
449 lua d.len = vim.funcref"Mylen" -- assign d as 'self' | 449 lua d.len = vim.funcref"Mylen" -- assign d as 'self' |
450 lua res = (d.len() == vim.funcref"len"(vim.eval"l")) and "OK" or "FAIL" | 450 lua res = (d.len() == vim.funcref"len"(vim.eval"l")) and "OK" or "FAIL" |
451 call assert_equal("OK", luaeval('res')) | 451 call assert_equal("OK", luaeval('res')) |
452 call assert_equal(function('Mylen', {'data': l, 'len': function('Mylen')}), mydict.len) | |
452 | 453 |
453 lua i1, i2, msg, d, res = nil | 454 lua i1, i2, msg, d, res = nil |
454 endfunc | 455 endfunc |
455 | 456 |
456 " Test vim.type() | 457 " Test vim.type() |