From 3fd9ffd36893cd82549956de6960282791573b87 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 9 Sep 2018 17:50:48 -0400 Subject: vim-patch:8.0.1377: cannot call a dict function in autoloaded dict Problem: Cannot call a dict function in autoloaded dict. Solution: Call get_lval() passing the read-only flag. https://github.com/vim/vim/commit/6e65d594aa33be11f6074f26e9ff81b52504c62b --- src/nvim/eval.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 541a255dcc..429e327028 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2076,7 +2076,11 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, return p; } - v = find_var(lp->ll_name, lp->ll_name_len, &ht, flags & GLV_NO_AUTOLOAD); + // Only pass &ht when we would write to the variable, it prevents autoload + // as well. + v = find_var(lp->ll_name, lp->ll_name_len, + (flags & GLV_READ_ONLY) ? NULL : &ht, + flags & GLV_NO_AUTOLOAD); if (v == NULL && !quiet) { emsgf(_("E121: Undefined variable: %.*s"), (int)lp->ll_name_len, lp->ll_name); @@ -18322,9 +18326,9 @@ varnumber_T get_vim_var_nr(int idx) FUNC_ATTR_PURE return vimvars[idx].vv_nr; } -/* - * Get string v: variable value. Uses a static buffer, can only be used once. - */ +// Get string v: variable value. Uses a static buffer, can only be used once. +// If the String variable has never been set, return an empty string. +// Never returns NULL; char_u *get_vim_var_str(int idx) FUNC_ATTR_PURE FUNC_ATTR_NONNULL_RET { return (char_u *)tv_get_string(&vimvars[idx].vv_tv); @@ -20360,7 +20364,7 @@ trans_function_name( } // Note that TFN_ flags use the same values as GLV_ flags. - end = get_lval((char_u *)start, NULL, &lv, false, skip, flags, + end = get_lval((char_u *)start, NULL, &lv, false, skip, flags | GLV_READ_ONLY, lead > 2 ? 0 : FNE_CHECK_START); if (end == start) { if (!skip) -- cgit From 39ab7cc6fb5948542f4ccc1d4067fdcca5183964 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 9 Sep 2018 20:28:07 -0400 Subject: vim-patch:8.0.1378: autoload script sources itself when defining function Problem: Autoload script sources itself when defining function. Solution: Pass TFN_NO_AUTOLOAD to trans_function_name(). (Yasuhiro Matsumoto, closes vim/vim#2423) https://github.com/vim/vim/commit/3388d334572f9d65a603d09d75e363805d96c5d9 --- src/nvim/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 429e327028..8d8fdab351 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -19820,7 +19820,7 @@ void ex_function(exarg_T *eap) // s:func script-local function name // g:func global function name, same as "func" p = eap->arg; - name = trans_function_name(&p, eap->skip, 0, &fudi, NULL); + name = trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL); paren = (vim_strchr(p, '(') != NULL); if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) { /* -- cgit