{
ufunc_T *ufunc = find_func(name, FALSE, NULL);
+ // In Vim9 script we can get a function reference by using the
+ // function name.
if (ufunc != NULL)
{
found = TRUE;
{
rettv->v_type = VAR_FUNC;
rettv->vval.v_string = vim_strsave(ufunc->uf_name);
+ if (rettv->vval.v_string != NULL)
+ func_ref(ufunc->uf_name);
}
}
}
call CheckDefAndScriptSuccess(lines)
enddef
+func CreateMydict()
+ let g:mydict = {}
+ func g:mydict.afunc()
+ let g:result = self.key
+ endfunc
+endfunc
+
+def Test_numbered_function_reference()
+ CreateMydict()
+ var output = execute('legacy func g:mydict.afunc')
+ var funcName = 'g:' .. substitute(output, '.*function \(\d\+\).*', '\1', '')
+ execute 'function(' .. funcName .. ', [], {key: 42})()'
+ # check that the function still exists
+ assert_equal(output, execute('legacy func g:mydict.afunc'))
+ unlet g:mydict
+enddef
+
if has('python3')
def Test_python3_heredoc()
py3 << trim EOF