Mercurial > vim
diff src/testdir/test_expr.vim @ 9723:80ac9cf77c9b v7.4.2137
commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 1 15:40:54 2016 +0200
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 01 Aug 2016 15:45:07 +0200 |
parents | 6226de5f8137 |
children | ba98d7ce0d74 |
line wrap: on
line diff
--- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -179,3 +179,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