diff src/eval.c @ 13002:f7b2ecaeb79c v8.0.1377

patch 8.0.1377: cannot call a dict function in autoloaded dict commit https://github.com/vim/vim/commit/6e65d594aa33be11f6074f26e9ff81b52504c62b Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 7 22:11:27 2017 +0100 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.
author Christian Brabandt <cb@256bit.org>
date Thu, 07 Dec 2017 22:15:06 +0100
parents 9c1659761fc3
children 6e81a68d63a1
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -1956,7 +1956,10 @@ get_lval(
 
     cc = *p;
     *p = NUL;
-    v = find_var(lp->ll_name, &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, (flags & GLV_READ_ONLY) ? NULL : &ht,
+						      flags & GLV_NO_AUTOLOAD);
     if (v == NULL && !quiet)
 	EMSG2(_(e_undefvar), lp->ll_name);
     *p = cc;
@@ -6610,6 +6613,8 @@ get_vim_var_nr(int idx)
 
 /*
  * 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)