From 53fad45115d3ee438dfb537d99ccf3b021ebc6b7 Mon Sep 17 00:00:00 2001 From: Michael Ennen Date: Fri, 16 Dec 2016 14:51:49 -0700 Subject: vim-patch:7.4.2137 Problem: Using function() with a name will find another function when it is redefined. Solution: Add funcref(). Refer to lambda using a partial. Fix several reference counting issues. https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c --- src/nvim/testdir/test_expr.vim | 15 +++++++++++++++ src/nvim/testdir/test_lambda.vim | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim index 7e43af9ebd..419d539b42 100644 --- a/src/nvim/testdir/test_expr.vim +++ b/src/nvim/testdir/test_expr.vim @@ -150,3 +150,18 @@ func Test_function_with_funcref() call assert_equal(v:t_string, s:fref('x')) call assert_fails("call function('s:f')", 'E700:') endfunc + +func Test_funcref() + func! One() + return 1 + endfunc + let OneByName = function('One') + let OneByRef = funcref('One') + func! One() + return 2 + endfunc + call assert_equal(2, OneByName()) + call assert_equal(1, OneByRef()) + let OneByRef = funcref('One') + call assert_equal(2, OneByRef()) +endfunc diff --git a/src/nvim/testdir/test_lambda.vim b/src/nvim/testdir/test_lambda.vim index d51b6f7c5a..00665810bd 100644 --- a/src/nvim/testdir/test_lambda.vim +++ b/src/nvim/testdir/test_lambda.vim @@ -259,10 +259,10 @@ endfunction func Test_closure_refcount() let g:Count = LambdaFoo() - call test_garbagecollect_now() + call garbagecollect() call assert_equal(1, g:Count()) let g:Count2 = LambdaFoo() - call test_garbagecollect_now() + call garbagecollect() call assert_equal(1, g:Count2()) call assert_equal(2, g:Count()) call assert_equal(3, g:Count2()) -- cgit