assert_equal(123, RefRef())
enddef
+def Test_partial_null_function()
+ var lines =<< trim END
+ var d: dict<func> = {f: null_function}
+ var Ref = d.f
+ assert_equal('func', typename(Ref))
+ END
+ v9.CheckDefAndScriptSuccess(lines)
+enddef
+
" Using "idx" from a legacy global function does not work.
" This caused a crash when called from legacy context.
func Test_partial_call_fails()
make_partial(dict_T *selfdict_in, typval_T *rettv)
{
char_u *fname;
- char_u *tofree = NULL;
ufunc_T *fp;
char_u fname_buf[FLEN_FIXED + 1];
int error;
{
fname = rettv->v_type == VAR_FUNC ? rettv->vval.v_string
: rettv->vval.v_partial->pt_name;
- // Translate "s:func" to the stored function name.
- fname = fname_trans_sid(fname, fname_buf, &tofree, &error);
- fp = find_func(fname, FALSE);
- vim_free(tofree);
+ if (fname != NULL)
+ {
+ char_u *tofree = NULL;
+
+ // Translate "s:func" to the stored function name.
+ fname = fname_trans_sid(fname, fname_buf, &tofree, &error);
+ fp = find_func(fname, FALSE);
+ vim_free(tofree);
+ }
}
- if (fp != NULL && (fp->uf_flags & FC_DICT))
+ if ((fp != NULL && (fp->uf_flags & FC_DICT))
+ || (rettv->v_type == VAR_FUNC && rettv->vval.v_string == NULL))
{
partial_T *pt = ALLOC_CLEAR_ONE(partial_T);