summaryrefslogtreecommitdiff
path: root/src/userfunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/userfunc.c')
-rw-r--r--src/userfunc.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/userfunc.c b/src/userfunc.c
index bf026d857..3e566f334 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -1148,6 +1148,8 @@ func_clear_free(ufunc_T *fp, int force)
func_clear(fp, force);
if (force || fp->uf_dfunc_idx == 0)
func_free(fp, force);
+ else
+ fp->uf_flags |= FC_DEAD;
}
@@ -2557,12 +2559,6 @@ def_function(exarg_T *eap, char_u *name_arg)
char_u *heredoc_trimmed = NULL;
int vim9script = in_vim9script();
- if (vim9script && eap->forceit)
- {
- emsg(_(e_nobang));
- return NULL;
- }
-
/*
* ":function" without argument: list functions.
*/
@@ -2732,6 +2728,13 @@ def_function(exarg_T *eap, char_u *name_arg)
}
p = skipwhite(p + 1);
+ // In Vim9 script only global functions can be redefined.
+ if (vim9script && eap->forceit && !is_global)
+ {
+ emsg(_(e_nobang));
+ goto ret_free;
+ }
+
ga_init2(&newlines, (int)sizeof(char_u *), 3);
if (!eap->skip && name_arg == NULL)