Mercurial > vim
diff src/userfunc.c @ 21479:90d859a402cc v8.2.1290
patch 8.2.1290: Vim9: cannot replace a global function
Commit: https://github.com/vim/vim/commit/925e9fd6339981c1015410e1b6a6dd19e34f36cc
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 25 15:41:11 2020 +0200
patch 8.2.1290: Vim9: cannot replace a global function
Problem: Vim9: cannot replace a global function.
Solution: Allow for "!" on a global function. (closes https://github.com/vim/vim/issues/6524) Also fix that
:delfunc on a :def function only made it empty.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 25 Jul 2020 15:45:04 +0200 |
parents | 4dfd00f481fb |
children | 574517d682cf |
line wrap: on
line diff
--- 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_ 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_ } 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)