comparison 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
comparison
equal deleted inserted replaced
21478:d452597ad7ff 21479:90d859a402cc
1146 func_clear_free(ufunc_T *fp, int force) 1146 func_clear_free(ufunc_T *fp, int force)
1147 { 1147 {
1148 func_clear(fp, force); 1148 func_clear(fp, force);
1149 if (force || fp->uf_dfunc_idx == 0) 1149 if (force || fp->uf_dfunc_idx == 0)
1150 func_free(fp, force); 1150 func_free(fp, force);
1151 else
1152 fp->uf_flags |= FC_DEAD;
1151 } 1153 }
1152 1154
1153 1155
1154 /* 1156 /*
1155 * Call a user function. 1157 * Call a user function.
2555 int is_heredoc = FALSE; 2557 int is_heredoc = FALSE;
2556 char_u *skip_until = NULL; 2558 char_u *skip_until = NULL;
2557 char_u *heredoc_trimmed = NULL; 2559 char_u *heredoc_trimmed = NULL;
2558 int vim9script = in_vim9script(); 2560 int vim9script = in_vim9script();
2559 2561
2560 if (vim9script && eap->forceit)
2561 {
2562 emsg(_(e_nobang));
2563 return NULL;
2564 }
2565
2566 /* 2562 /*
2567 * ":function" without argument: list functions. 2563 * ":function" without argument: list functions.
2568 */ 2564 */
2569 if (ends_excmd2(eap->cmd, eap->arg)) 2565 if (ends_excmd2(eap->cmd, eap->arg))
2570 { 2566 {
2729 // attempt to continue by skipping some text 2725 // attempt to continue by skipping some text
2730 if (vim_strchr(p, '(') != NULL) 2726 if (vim_strchr(p, '(') != NULL)
2731 p = vim_strchr(p, '('); 2727 p = vim_strchr(p, '(');
2732 } 2728 }
2733 p = skipwhite(p + 1); 2729 p = skipwhite(p + 1);
2730
2731 // In Vim9 script only global functions can be redefined.
2732 if (vim9script && eap->forceit && !is_global)
2733 {
2734 emsg(_(e_nobang));
2735 goto ret_free;
2736 }
2734 2737
2735 ga_init2(&newlines, (int)sizeof(char_u *), 3); 2738 ga_init2(&newlines, (int)sizeof(char_u *), 3);
2736 2739
2737 if (!eap->skip && name_arg == NULL) 2740 if (!eap->skip && name_arg == NULL)
2738 { 2741 {