Mercurial > vim
diff src/userfunc.c @ 20339:7587d892c00c v8.2.0725
patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Commit: https://github.com/vim/vim/commit/09689a02840be40fa7bb10b1921fb5bc5b2908f1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 9 22:50:08 2020 +0200
patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script
Problem: Vim9: cannot call a function declared later in Vim9 script.
Solution: Make two passes through the script file.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 09 May 2020 23:00:04 +0200 |
parents | 49b50843e725 |
children | 4c317d8c1051 |
line wrap: on
line diff
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -2378,7 +2378,7 @@ untrans_function_name(char_u *name) * Returns a pointer to the function or NULL if no function defined. */ ufunc_T * -def_function(exarg_T *eap, char_u *name_arg, void *context) +def_function(exarg_T *eap, char_u *name_arg, void *context, int compile) { char_u *theline; char_u *line_to_free = NULL; @@ -3241,6 +3241,7 @@ def_function(exarg_T *eap, char_u *name_ p = ret_type; fp->uf_ret_type = parse_type(&p, &fp->uf_type_list); } + SOURCING_LNUM = lnum_save; } fp->uf_lines = newlines; @@ -3273,8 +3274,8 @@ def_function(exarg_T *eap, char_u *name_ is_export = FALSE; } - // ":def Func()" needs to be compiled - if (eap->cmdidx == CMD_def) + // ":def Func()" may need to be compiled + if (eap->cmdidx == CMD_def && compile) compile_def_function(fp, FALSE, context); goto ret_free; @@ -3304,7 +3305,7 @@ ret_free: void ex_function(exarg_T *eap) { - def_function(eap, NULL, NULL); + (void)def_function(eap, NULL, NULL, TRUE); } /*