diff options
| author | Michael Ennen <mike.ennen@gmail.com> | 2016-10-26 21:40:40 -0700 |
|---|---|---|
| committer | James McCoy <jamessan@jamessan.com> | 2016-12-12 10:17:35 -0500 |
| commit | e2258598cacebf3c90bbb8e13789194c417d8dad (patch) | |
| tree | d6eba9675ade2138b0ff566a50662878c5c8a79e /src/nvim/testdir | |
| parent | 5cf0c99755581f789973a4fa4bb3d95a61a01341 (diff) | |
| download | rneovim-e2258598cacebf3c90bbb8e13789194c417d8dad.tar.gz rneovim-e2258598cacebf3c90bbb8e13789194c417d8dad.tar.bz2 rneovim-e2258598cacebf3c90bbb8e13789194c417d8dad.zip | |
vim-patch:7.4.1582
Problem: Get E923 when using function(dict.func, [], dict). (Kent Sibilev)
Storing a function with a dict in a variable drops the dict if the
function is script-local.
Solution: Translate the function name. Use dict arg if present.
https://github.com/vim/vim/commit/6f2e4b36c9d9908e1cace2b1b96e2c154a837bc2
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_partial.vim | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/nvim/testdir/test_partial.vim b/src/nvim/testdir/test_partial.vim index cb853f9335..7941ec01c2 100644 --- a/src/nvim/testdir/test_partial.vim +++ b/src/nvim/testdir/test_partial.vim @@ -69,8 +69,6 @@ func Test_partial_implicit() let Func = function(dict.MyFunc, ['bbb']) call assert_equal('foo/bbb', Func()) - - call assert_fails('call function(dict.MyFunc, ["bbb"], dict)', 'E924:') endfunc fun InnerCall(funcref) @@ -86,3 +84,24 @@ func Test_function_in_dict() call OuterCall() endfunc +function! s:cache_clear() dict + return self.name +endfunction + +func Test_script_function_in_dict() + let s:obj = {'name': 'foo'} + let s:obj2 = {'name': 'bar'} + + let s:obj['clear'] = function('s:cache_clear') + + call assert_equal('foo', s:obj.clear()) + let F = s:obj.clear + call assert_equal('foo', F()) + call assert_equal('foo', call(s:obj.clear, [], s:obj)) + call assert_equal('bar', call(s:obj.clear, [], s:obj2)) + + let s:obj2['clear'] = function('s:cache_clear') + call assert_equal('bar', s:obj2.clear()) + let B = s:obj2.clear + call assert_equal('bar', B()) +endfunc |