Blame SOURCES/7.4.149

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.149
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.149
22c937
Problem:    Get E685 error when assigning a function to an autoload variable.
22c937
	    (Yukihiro Nakadaira)
22c937
Solution:   Instead of having a global no_autoload variable, pass an autoload
22c937
	    flag down to where it is used. (ZyX)
22c937
Files:	    src/eval.c, src/testdir/test55.in, src/testdir/test55.ok,
22c937
	    src/testdir/test60.in, src/testdir/test60.ok,
22c937
	    src/testdir/sautest/autoload/footest.vim
22c937
22c937
22c937
*** ../vim-7.4.148/src/eval.c	2014-01-06 06:18:44.000000000 +0100
22c937
--- src/eval.c	2014-01-14 15:14:05.000000000 +0100
22c937
***************
22c937
*** 125,133 ****
22c937
   */
22c937
  static hashtab_T	compat_hashtab;
22c937
  
22c937
- /* When using exists() don't auto-load a script. */
22c937
- static int		no_autoload = FALSE;
22c937
- 
22c937
  /*
22c937
   * When recursively copying lists and dicts we need to remember which ones we
22c937
   * have done to avoid endless recursiveness.  This unique ID is used for that.
22c937
--- 125,130 ----
22c937
***************
22c937
*** 156,161 ****
22c937
--- 153,163 ----
22c937
  /* Values for trans_function_name() argument: */
22c937
  #define TFN_INT		1	/* internal function name OK */
22c937
  #define TFN_QUIET	2	/* no error messages */
22c937
+ #define TFN_NO_AUTOLOAD	4	/* do not use script autoloading */
22c937
+ 
22c937
+ /* Values for get_lval() flags argument: */
22c937
+ #define GLV_QUIET	TFN_QUIET	/* no error messages */
22c937
+ #define GLV_NO_AUTOLOAD	TFN_NO_AUTOLOAD	/* do not use script autoloading */
22c937
  
22c937
  /*
22c937
   * Structure to hold info for a user function.
22c937
***************
22c937
*** 390,396 ****
22c937
  static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg, int *first));
22c937
  static char_u *ex_let_one __ARGS((char_u *arg, typval_T *tv, int copy, char_u *endchars, char_u *op));
22c937
  static int check_changedtick __ARGS((char_u *arg));
22c937
! static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int unlet, int skip, int quiet, int fne_flags));
22c937
  static void clear_lval __ARGS((lval_T *lp));
22c937
  static void set_var_lval __ARGS((lval_T *lp, char_u *endp, typval_T *rettv, int copy, char_u *op));
22c937
  static int tv_op __ARGS((typval_T *tv1, typval_T *tv2, char_u  *op));
22c937
--- 392,398 ----
22c937
  static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg, int *first));
22c937
  static char_u *ex_let_one __ARGS((char_u *arg, typval_T *tv, int copy, char_u *endchars, char_u *op));
22c937
  static int check_changedtick __ARGS((char_u *arg));
22c937
! static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int unlet, int skip, int flags, int fne_flags));
22c937
  static void clear_lval __ARGS((lval_T *lp));
22c937
  static void set_var_lval __ARGS((lval_T *lp, char_u *endp, typval_T *rettv, int copy, char_u *op));
22c937
  static int tv_op __ARGS((typval_T *tv1, typval_T *tv2, char_u  *op));
22c937
***************
22c937
*** 770,776 ****
22c937
  static char_u * make_expanded_name __ARGS((char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end));
22c937
  static int eval_isnamec __ARGS((int c));
22c937
  static int eval_isnamec1 __ARGS((int c));
22c937
! static int get_var_tv __ARGS((char_u *name, int len, typval_T *rettv, int verbose));
22c937
  static int handle_subscript __ARGS((char_u **arg, typval_T *rettv, int evaluate, int verbose));
22c937
  static typval_T *alloc_tv __ARGS((void));
22c937
  static typval_T *alloc_string_tv __ARGS((char_u *string));
22c937
--- 772,778 ----
22c937
  static char_u * make_expanded_name __ARGS((char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end));
22c937
  static int eval_isnamec __ARGS((int c));
22c937
  static int eval_isnamec1 __ARGS((int c));
22c937
! static int get_var_tv __ARGS((char_u *name, int len, typval_T *rettv, int verbose, int no_autoload));
22c937
  static int handle_subscript __ARGS((char_u **arg, typval_T *rettv, int evaluate, int verbose));
22c937
  static typval_T *alloc_tv __ARGS((void));
22c937
  static typval_T *alloc_string_tv __ARGS((char_u *string));
22c937
***************
22c937
*** 781,788 ****
22c937
  static char_u *get_tv_string __ARGS((typval_T *varp));
22c937
  static char_u *get_tv_string_buf __ARGS((typval_T *varp, char_u *buf));
22c937
  static char_u *get_tv_string_buf_chk __ARGS((typval_T *varp, char_u *buf));
22c937
! static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp));
22c937
! static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, int htname, char_u *varname, int writing));
22c937
  static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname));
22c937
  static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val));
22c937
  static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi));
22c937
--- 783,790 ----
22c937
  static char_u *get_tv_string __ARGS((typval_T *varp));
22c937
  static char_u *get_tv_string_buf __ARGS((typval_T *varp, char_u *buf));
22c937
  static char_u *get_tv_string_buf_chk __ARGS((typval_T *varp, char_u *buf));
22c937
! static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp, int no_autoload));
22c937
! static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, int htname, char_u *varname, int no_autoload));
22c937
  static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname));
22c937
  static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val));
22c937
  static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi));
22c937
***************
22c937
*** 1059,1065 ****
22c937
      ga_init2(&redir_ga, (int)sizeof(char), 500);
22c937
  
22c937
      /* Parse the variable name (can be a dict or list entry). */
22c937
!     redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, FALSE,
22c937
  							     FNE_CHECK_START);
22c937
      if (redir_endp == NULL || redir_lval->ll_name == NULL || *redir_endp != NUL)
22c937
      {
22c937
--- 1061,1067 ----
22c937
      ga_init2(&redir_ga, (int)sizeof(char), 500);
22c937
  
22c937
      /* Parse the variable name (can be a dict or list entry). */
22c937
!     redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, 0,
22c937
  							     FNE_CHECK_START);
22c937
      if (redir_endp == NULL || redir_lval->ll_name == NULL || *redir_endp != NUL)
22c937
      {
22c937
***************
22c937
*** 1150,1156 ****
22c937
  	    /* Call get_lval() again, if it's inside a Dict or List it may
22c937
  	     * have changed. */
22c937
  	    redir_endp = get_lval(redir_varname, NULL, redir_lval,
22c937
! 					FALSE, FALSE, FALSE, FNE_CHECK_START);
22c937
  	    if (redir_endp != NULL && redir_lval->ll_name != NULL)
22c937
  		set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
22c937
  	    clear_lval(redir_lval);
22c937
--- 1152,1158 ----
22c937
  	    /* Call get_lval() again, if it's inside a Dict or List it may
22c937
  	     * have changed. */
22c937
  	    redir_endp = get_lval(redir_varname, NULL, redir_lval,
22c937
! 					FALSE, FALSE, 0, FNE_CHECK_START);
22c937
  	    if (redir_endp != NULL && redir_lval->ll_name != NULL)
22c937
  		set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
22c937
  	    clear_lval(redir_lval);
22c937
***************
22c937
*** 2239,2245 ****
22c937
  	    {
22c937
  		if (tofree != NULL)
22c937
  		    name = tofree;
22c937
! 		if (get_var_tv(name, len, &tv, TRUE) == FAIL)
22c937
  		    error = TRUE;
22c937
  		else
22c937
  		{
22c937
--- 2241,2247 ----
22c937
  	    {
22c937
  		if (tofree != NULL)
22c937
  		    name = tofree;
22c937
! 		if (get_var_tv(name, len, &tv, TRUE, FALSE) == FAIL)
22c937
  		    error = TRUE;
22c937
  		else
22c937
  		{
22c937
***************
22c937
*** 2474,2480 ****
22c937
      {
22c937
  	lval_T	lv;
22c937
  
22c937
! 	p = get_lval(arg, tv, &lv, FALSE, FALSE, FALSE, FNE_CHECK_START);
22c937
  	if (p != NULL && lv.ll_name != NULL)
22c937
  	{
22c937
  	    if (endchars != NULL && vim_strchr(endchars, *skipwhite(p)) == NULL)
22c937
--- 2476,2482 ----
22c937
      {
22c937
  	lval_T	lv;
22c937
  
22c937
! 	p = get_lval(arg, tv, &lv, FALSE, FALSE, 0, FNE_CHECK_START);
22c937
  	if (p != NULL && lv.ll_name != NULL)
22c937
  	{
22c937
  	    if (endchars != NULL && vim_strchr(endchars, *skipwhite(p)) == NULL)
22c937
***************
22c937
*** 2519,2536 ****
22c937
   * "unlet" is TRUE for ":unlet": slightly different behavior when something is
22c937
   * wrong; must end in space or cmd separator.
22c937
   *
22c937
   * Returns a pointer to just after the name, including indexes.
22c937
   * When an evaluation error occurs "lp->ll_name" is NULL;
22c937
   * Returns NULL for a parsing error.  Still need to free items in "lp"!
22c937
   */
22c937
      static char_u *
22c937
! get_lval(name, rettv, lp, unlet, skip, quiet, fne_flags)
22c937
      char_u	*name;
22c937
      typval_T	*rettv;
22c937
      lval_T	*lp;
22c937
      int		unlet;
22c937
      int		skip;
22c937
!     int		quiet;	    /* don't give error messages */
22c937
      int		fne_flags;  /* flags for find_name_end() */
22c937
  {
22c937
      char_u	*p;
22c937
--- 2521,2542 ----
22c937
   * "unlet" is TRUE for ":unlet": slightly different behavior when something is
22c937
   * wrong; must end in space or cmd separator.
22c937
   *
22c937
+  * flags:
22c937
+  *  GLV_QUIET:       do not give error messages
22c937
+  *  GLV_NO_AUTOLOAD: do not use script autoloading
22c937
+  *
22c937
   * Returns a pointer to just after the name, including indexes.
22c937
   * When an evaluation error occurs "lp->ll_name" is NULL;
22c937
   * Returns NULL for a parsing error.  Still need to free items in "lp"!
22c937
   */
22c937
      static char_u *
22c937
! get_lval(name, rettv, lp, unlet, skip, flags, fne_flags)
22c937
      char_u	*name;
22c937
      typval_T	*rettv;
22c937
      lval_T	*lp;
22c937
      int		unlet;
22c937
      int		skip;
22c937
!     int		flags;	    /* GLV_ values */
22c937
      int		fne_flags;  /* flags for find_name_end() */
22c937
  {
22c937
      char_u	*p;
22c937
***************
22c937
*** 2544,2549 ****
22c937
--- 2550,2556 ----
22c937
      char_u	*key = NULL;
22c937
      int		len;
22c937
      hashtab_T	*ht;
22c937
+     int		quiet = flags & GLV_QUIET;
22c937
  
22c937
      /* Clear everything in "lp". */
22c937
      vim_memset(lp, 0, sizeof(lval_T));
22c937
***************
22c937
*** 2591,2597 ****
22c937
  
22c937
      cc = *p;
22c937
      *p = NUL;
22c937
!     v = find_var(lp->ll_name, &ht;;
22c937
      if (v == NULL && !quiet)
22c937
  	EMSG2(_(e_undefvar), lp->ll_name);
22c937
      *p = cc;
22c937
--- 2598,2604 ----
22c937
  
22c937
      cc = *p;
22c937
      *p = NUL;
22c937
!     v = find_var(lp->ll_name, &ht, flags & GLV_NO_AUTOLOAD);
22c937
      if (v == NULL && !quiet)
22c937
  	EMSG2(_(e_undefvar), lp->ll_name);
22c937
      *p = cc;
22c937
***************
22c937
*** 2904,2910 ****
22c937
  
22c937
  		/* handle +=, -= and .= */
22c937
  		if (get_var_tv(lp->ll_name, (int)STRLEN(lp->ll_name),
22c937
! 							     &tv, TRUE) == OK)
22c937
  		{
22c937
  		    if (tv_op(&tv, rettv, op) == OK)
22c937
  			set_var(lp->ll_name, &tv, FALSE);
22c937
--- 2911,2917 ----
22c937
  
22c937
  		/* handle +=, -= and .= */
22c937
  		if (get_var_tv(lp->ll_name, (int)STRLEN(lp->ll_name),
22c937
! 						      &tv, TRUE, FALSE) == OK)
22c937
  		{
22c937
  		    if (tv_op(&tv, rettv, op) == OK)
22c937
  			set_var(lp->ll_name, &tv, FALSE);
22c937
***************
22c937
*** 3556,3562 ****
22c937
      do
22c937
      {
22c937
  	/* Parse the name and find the end. */
22c937
! 	name_end = get_lval(arg, NULL, &lv, TRUE, eap->skip || error, FALSE,
22c937
  							     FNE_CHECK_START);
22c937
  	if (lv.ll_name == NULL)
22c937
  	    error = TRUE;	    /* error but continue parsing */
22c937
--- 3563,3569 ----
22c937
      do
22c937
      {
22c937
  	/* Parse the name and find the end. */
22c937
! 	name_end = get_lval(arg, NULL, &lv, TRUE, eap->skip || error, 0,
22c937
  							     FNE_CHECK_START);
22c937
  	if (lv.ll_name == NULL)
22c937
  	    error = TRUE;	    /* error but continue parsing */
22c937
***************
22c937
*** 3709,3715 ****
22c937
  	    ret = FAIL;
22c937
  	else
22c937
  	{
22c937
! 	    di = find_var(lp->ll_name, NULL);
22c937
  	    if (di == NULL)
22c937
  		ret = FAIL;
22c937
  	    else
22c937
--- 3716,3722 ----
22c937
  	    ret = FAIL;
22c937
  	else
22c937
  	{
22c937
! 	    di = find_var(lp->ll_name, NULL, TRUE);
22c937
  	    if (di == NULL)
22c937
  		ret = FAIL;
22c937
  	    else
22c937
***************
22c937
*** 5179,5185 ****
22c937
  		}
22c937
  	    }
22c937
  	    else if (evaluate)
22c937
! 		ret = get_var_tv(s, len, rettv, TRUE);
22c937
  	    else
22c937
  		ret = OK;
22c937
  	}
22c937
--- 5186,5192 ----
22c937
  		}
22c937
  	    }
22c937
  	    else if (evaluate)
22c937
! 		ret = get_var_tv(s, len, rettv, TRUE, FALSE);
22c937
  	    else
22c937
  		ret = OK;
22c937
  	}
22c937
***************
22c937
*** 8284,8290 ****
22c937
  
22c937
      cc = name[*lenp];
22c937
      name[*lenp] = NUL;
22c937
!     v = find_var(name, NULL);
22c937
      name[*lenp] = cc;
22c937
      if (v != NULL && v->di_tv.v_type == VAR_FUNC)
22c937
      {
22c937
--- 8291,8297 ----
22c937
  
22c937
      cc = name[*lenp];
22c937
      name[*lenp] = NUL;
22c937
!     v = find_var(name, NULL, FALSE);
22c937
      name[*lenp] = cc;
22c937
      if (v != NULL && v->di_tv.v_type == VAR_FUNC)
22c937
      {
22c937
***************
22c937
*** 10039,10046 ****
22c937
      int		n = FALSE;
22c937
      int		len = 0;
22c937
  
22c937
-     no_autoload = TRUE;
22c937
- 
22c937
      p = get_tv_string(&argvars[0]);
22c937
      if (*p == '$')			/* environment variable */
22c937
      {
22c937
--- 10046,10051 ----
22c937
***************
22c937
*** 10091,10097 ****
22c937
  	{
22c937
  	    if (tofree != NULL)
22c937
  		name = tofree;
22c937
! 	    n = (get_var_tv(name, len, &tv, FALSE) == OK);
22c937
  	    if (n)
22c937
  	    {
22c937
  		/* handle d.key, l[idx], f(expr) */
22c937
--- 10096,10102 ----
22c937
  	{
22c937
  	    if (tofree != NULL)
22c937
  		name = tofree;
22c937
! 	    n = (get_var_tv(name, len, &tv, FALSE, TRUE) == OK);
22c937
  	    if (n)
22c937
  	    {
22c937
  		/* handle d.key, l[idx], f(expr) */
22c937
***************
22c937
*** 10107,10114 ****
22c937
      }
22c937
  
22c937
      rettv->vval.v_number = n;
22c937
- 
22c937
-     no_autoload = FALSE;
22c937
  }
22c937
  
22c937
  #ifdef FEAT_FLOAT
22c937
--- 10112,10117 ----
22c937
***************
22c937
*** 13344,13351 ****
22c937
      dictitem_T	*di;
22c937
  
22c937
      rettv->vval.v_number = -1;
22c937
!     end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE, FALSE,
22c937
! 							     FNE_CHECK_START);
22c937
      if (end != NULL && lv.ll_name != NULL)
22c937
      {
22c937
  	if (*end != NUL)
22c937
--- 13347,13354 ----
22c937
      dictitem_T	*di;
22c937
  
22c937
      rettv->vval.v_number = -1;
22c937
!     end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE,
22c937
! 					GLV_NO_AUTOLOAD, FNE_CHECK_START);
22c937
      if (end != NULL && lv.ll_name != NULL)
22c937
      {
22c937
  	if (*end != NUL)
22c937
***************
22c937
*** 13358,13364 ****
22c937
  		    rettv->vval.v_number = 1;	    /* always locked */
22c937
  		else
22c937
  		{
22c937
! 		    di = find_var(lv.ll_name, NULL);
22c937
  		    if (di != NULL)
22c937
  		    {
22c937
  			/* Consider a variable locked when:
22c937
--- 13361,13367 ----
22c937
  		    rettv->vval.v_number = 1;	    /* always locked */
22c937
  		else
22c937
  		{
22c937
! 		    di = find_var(lv.ll_name, NULL, TRUE);
22c937
  		    if (di != NULL)
22c937
  		    {
22c937
  			/* Consider a variable locked when:
22c937
***************
22c937
*** 19774,19784 ****
22c937
   * Return OK or FAIL.
22c937
   */
22c937
      static int
22c937
! get_var_tv(name, len, rettv, verbose)
22c937
      char_u	*name;
22c937
      int		len;		/* length of "name" */
22c937
      typval_T	*rettv;		/* NULL when only checking existence */
22c937
      int		verbose;	/* may give error message */
22c937
  {
22c937
      int		ret = OK;
22c937
      typval_T	*tv = NULL;
22c937
--- 19777,19788 ----
22c937
   * Return OK or FAIL.
22c937
   */
22c937
      static int
22c937
! get_var_tv(name, len, rettv, verbose, no_autoload)
22c937
      char_u	*name;
22c937
      int		len;		/* length of "name" */
22c937
      typval_T	*rettv;		/* NULL when only checking existence */
22c937
      int		verbose;	/* may give error message */
22c937
+     int		no_autoload;	/* do not use script autoloading */
22c937
  {
22c937
      int		ret = OK;
22c937
      typval_T	*tv = NULL;
22c937
***************
22c937
*** 19805,19811 ****
22c937
       */
22c937
      else
22c937
      {
22c937
! 	v = find_var(name, NULL);
22c937
  	if (v != NULL)
22c937
  	    tv = &v->di_tv;
22c937
      }
22c937
--- 19809,19815 ----
22c937
       */
22c937
      else
22c937
      {
22c937
! 	v = find_var(name, NULL, no_autoload);
22c937
  	if (v != NULL)
22c937
  	    tv = &v->di_tv;
22c937
      }
22c937
***************
22c937
*** 20207,20215 ****
22c937
   * hashtab_T used.
22c937
   */
22c937
      static dictitem_T *
22c937
! find_var(name, htp)
22c937
      char_u	*name;
22c937
      hashtab_T	**htp;
22c937
  {
22c937
      char_u	*varname;
22c937
      hashtab_T	*ht;
22c937
--- 20211,20220 ----
22c937
   * hashtab_T used.
22c937
   */
22c937
      static dictitem_T *
22c937
! find_var(name, htp, no_autoload)
22c937
      char_u	*name;
22c937
      hashtab_T	**htp;
22c937
+     int		no_autoload;
22c937
  {
22c937
      char_u	*varname;
22c937
      hashtab_T	*ht;
22c937
***************
22c937
*** 20219,20225 ****
22c937
  	*htp = ht;
22c937
      if (ht == NULL)
22c937
  	return NULL;
22c937
!     return find_var_in_ht(ht, *name, varname, htp != NULL);
22c937
  }
22c937
  
22c937
  /*
22c937
--- 20224,20230 ----
22c937
  	*htp = ht;
22c937
      if (ht == NULL)
22c937
  	return NULL;
22c937
!     return find_var_in_ht(ht, *name, varname, no_autoload || htp != NULL);
22c937
  }
22c937
  
22c937
  /*
22c937
***************
22c937
*** 20227,20237 ****
22c937
   * Returns NULL if not found.
22c937
   */
22c937
      static dictitem_T *
22c937
! find_var_in_ht(ht, htname, varname, writing)
22c937
      hashtab_T	*ht;
22c937
      int		htname;
22c937
      char_u	*varname;
22c937
!     int		writing;
22c937
  {
22c937
      hashitem_T	*hi;
22c937
  
22c937
--- 20232,20242 ----
22c937
   * Returns NULL if not found.
22c937
   */
22c937
      static dictitem_T *
22c937
! find_var_in_ht(ht, htname, varname, no_autoload)
22c937
      hashtab_T	*ht;
22c937
      int		htname;
22c937
      char_u	*varname;
22c937
!     int		no_autoload;
22c937
  {
22c937
      hashitem_T	*hi;
22c937
  
22c937
***************
22c937
*** 20263,20269 ****
22c937
  	 * worked find the variable again.  Don't auto-load a script if it was
22c937
  	 * loaded already, otherwise it would be loaded every time when
22c937
  	 * checking if a function name is a Funcref variable. */
22c937
! 	if (ht == &globvarht && !writing)
22c937
  	{
22c937
  	    /* Note: script_autoload() may make "hi" invalid. It must either
22c937
  	     * be obtained again or not used. */
22c937
--- 20268,20274 ----
22c937
  	 * worked find the variable again.  Don't auto-load a script if it was
22c937
  	 * loaded already, otherwise it would be loaded every time when
22c937
  	 * checking if a function name is a Funcref variable. */
22c937
! 	if (ht == &globvarht && !no_autoload)
22c937
  	{
22c937
  	    /* Note: script_autoload() may make "hi" invalid. It must either
22c937
  	     * be obtained again or not used. */
22c937
***************
22c937
*** 20343,20349 ****
22c937
  {
22c937
      dictitem_T	*v;
22c937
  
22c937
!     v = find_var(name, NULL);
22c937
      if (v == NULL)
22c937
  	return NULL;
22c937
      return get_tv_string(&v->di_tv);
22c937
--- 20348,20354 ----
22c937
  {
22c937
      dictitem_T	*v;
22c937
  
22c937
!     v = find_var(name, NULL, FALSE);
22c937
      if (v == NULL)
22c937
  	return NULL;
22c937
      return get_tv_string(&v->di_tv);
22c937
***************
22c937
*** 21672,21678 ****
22c937
       */
22c937
      if (fudi.fd_dict == NULL)
22c937
      {
22c937
! 	v = find_var(name, &ht;;
22c937
  	if (v != NULL && v->di_tv.v_type == VAR_FUNC)
22c937
  	{
22c937
  	    emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
22c937
--- 21677,21683 ----
22c937
       */
22c937
      if (fudi.fd_dict == NULL)
22c937
      {
22c937
! 	v = find_var(name, &ht, FALSE);
22c937
  	if (v != NULL && v->di_tv.v_type == VAR_FUNC)
22c937
  	{
22c937
  	    emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
22c937
***************
22c937
*** 21830,21837 ****
22c937
   * Also handles a Funcref in a List or Dictionary.
22c937
   * Returns the function name in allocated memory, or NULL for failure.
22c937
   * flags:
22c937
!  * TFN_INT:   internal function name OK
22c937
!  * TFN_QUIET: be quiet
22c937
   * Advances "pp" to just after the function name (if no error).
22c937
   */
22c937
      static char_u *
22c937
--- 21835,21843 ----
22c937
   * Also handles a Funcref in a List or Dictionary.
22c937
   * Returns the function name in allocated memory, or NULL for failure.
22c937
   * flags:
22c937
!  * TFN_INT:         internal function name OK
22c937
!  * TFN_QUIET:       be quiet
22c937
!  * TFN_NO_AUTOLOAD: do not use script autoloading
22c937
   * Advances "pp" to just after the function name (if no error).
22c937
   */
22c937
      static char_u *
22c937
***************
22c937
*** 21869,21875 ****
22c937
      if (lead > 2)
22c937
  	start += lead;
22c937
  
22c937
!     end = get_lval(start, NULL, &lv, FALSE, skip, flags & TFN_QUIET,
22c937
  					      lead > 2 ? 0 : FNE_CHECK_START);
22c937
      if (end == start)
22c937
      {
22c937
--- 21875,21882 ----
22c937
      if (lead > 2)
22c937
  	start += lead;
22c937
  
22c937
!     /* Note that TFN_ flags use the same values as GLV_ flags. */
22c937
!     end = get_lval(start, NULL, &lv, FALSE, skip, flags,
22c937
  					      lead > 2 ? 0 : FNE_CHECK_START);
22c937
      if (end == start)
22c937
      {
22c937
***************
22c937
*** 22146,22152 ****
22c937
      char_u  *p;
22c937
      int	    n = FALSE;
22c937
  
22c937
!     p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET, NULL);
22c937
      nm = skipwhite(nm);
22c937
  
22c937
      /* Only accept "funcname", "funcname ", "funcname (..." and
22c937
--- 22153,22160 ----
22c937
      char_u  *p;
22c937
      int	    n = FALSE;
22c937
  
22c937
!     p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET|TFN_NO_AUTOLOAD,
22c937
! 			    NULL);
22c937
      nm = skipwhite(nm);
22c937
  
22c937
      /* Only accept "funcname", "funcname ", "funcname (..." and
22c937
***************
22c937
*** 22393,22402 ****
22c937
      int		ret = FALSE;
22c937
      int		i;
22c937
  
22c937
-     /* Return quickly when autoload disabled. */
22c937
-     if (no_autoload)
22c937
- 	return FALSE;
22c937
- 
22c937
      /* If there is no '#' after name[0] there is no package name. */
22c937
      p = vim_strchr(name, AUTOLOAD_CHAR);
22c937
      if (p == NULL || p == name)
22c937
--- 22401,22406 ----
22c937
*** ../vim-7.4.148/src/testdir/test55.in	2013-03-07 14:33:12.000000000 +0100
22c937
--- src/testdir/test55.in	2014-01-14 14:48:10.000000000 +0100
22c937
***************
22c937
*** 282,287 ****
22c937
--- 282,294 ----
22c937
  :    $put =ps
22c937
  :  endfor
22c937
  :endfor
22c937
+ :" :lockvar/islocked() triggering script autoloading
22c937
+ :set rtp+=./sautest
22c937
+ :lockvar g:footest#x
22c937
+ :unlockvar g:footest#x
22c937
+ :$put ='locked g:footest#x:'.islocked('g:footest#x')
22c937
+ :$put ='exists g:footest#x:'.exists('g:footest#x')
22c937
+ :$put ='g:footest#x: '.g:footest#x
22c937
  :"
22c937
  :" a:000 function argument
22c937
  :" first the tests that should fail
22c937
*** ../vim-7.4.148/src/testdir/test55.ok	2012-08-29 16:51:15.000000000 +0200
22c937
--- src/testdir/test55.ok	2014-01-14 14:45:14.000000000 +0100
22c937
***************
22c937
*** 86,91 ****
22c937
--- 86,94 ----
22c937
  FFpFFpp
22c937
  0000-000
22c937
  ppppppp
22c937
+ locked g:footest#x:-1
22c937
+ exists g:footest#x:0
22c937
+ g:footest#x: 1
22c937
  caught a:000
22c937
  caught a:000[0]
22c937
  caught a:000[2]
22c937
*** ../vim-7.4.148/src/testdir/test60.in	2010-05-15 13:04:10.000000000 +0200
22c937
--- src/testdir/test60.in	2014-01-14 14:49:10.000000000 +0100
22c937
***************
22c937
*** 1,4 ****
22c937
! Tests for the exists() function.  vim: set ft=vim :
22c937
  
22c937
  STARTTEST
22c937
  :so small.vim
22c937
--- 1,4 ----
22c937
! Tests for the exists() function.  vim: set ft=vim ts=8 :
22c937
  
22c937
  STARTTEST
22c937
  :so small.vim
22c937
***************
22c937
*** 11,18 ****
22c937
  endfunction
22c937
  :function! TestExists()
22c937
      augroup myagroup
22c937
! 	autocmd! BufEnter *.my echo 'myfile edited'
22c937
      augroup END
22c937
  
22c937
      let test_cases = []
22c937
  
22c937
--- 11,20 ----
22c937
  endfunction
22c937
  :function! TestExists()
22c937
      augroup myagroup
22c937
! 	autocmd! BufEnter       *.my     echo "myfile edited"
22c937
! 	autocmd! FuncUndefined  UndefFun exec "fu UndefFun()\nendfu"
22c937
      augroup END
22c937
+     set rtp+=./sautest
22c937
  
22c937
      let test_cases = []
22c937
  
22c937
***************
22c937
*** 95,104 ****
22c937
      " Non-existing user defined function
22c937
      let test_cases += [['*MyxyzFunc', 0]]
22c937
  
22c937
      redir! > test.out
22c937
  
22c937
      for [test_case, result] in test_cases
22c937
!       	echo test_case . ": " . result
22c937
          call RunTest(test_case, result)
22c937
      endfor
22c937
  
22c937
--- 97,111 ----
22c937
      " Non-existing user defined function
22c937
      let test_cases += [['*MyxyzFunc', 0]]
22c937
  
22c937
+     " Function that may be created by FuncUndefined event
22c937
+     let test_cases += [['*UndefFun', 0]]
22c937
+     " Function that may be created by script autoloading
22c937
+     let test_cases += [['*footest#F', 0]]
22c937
+ 
22c937
      redir! > test.out
22c937
  
22c937
      for [test_case, result] in test_cases
22c937
!         echo test_case . ": " . result
22c937
          call RunTest(test_case, result)
22c937
      endfor
22c937
  
22c937
***************
22c937
*** 207,212 ****
22c937
--- 214,227 ----
22c937
  	echo "FAILED"
22c937
      endif
22c937
  
22c937
+     " Non-existing autoload variable that may be autoloaded
22c937
+     echo 'footest#x: 0'
22c937
+     if !exists('footest#x')
22c937
+ 	echo "OK"
22c937
+     else
22c937
+ 	echo "FAILED"
22c937
+     endif
22c937
+ 
22c937
      " Valid local list
22c937
      let local_list = ["blue", "orange"]
22c937
      echo 'local_list: 1'
22c937
***************
22c937
*** 566,571 ****
22c937
--- 581,590 ----
22c937
  
22c937
      call TestFuncArg("arg1", "arg2")
22c937
  
22c937
+     echo ' g:footest#x =' g:footest#x
22c937
+     echo '   footest#F()' footest#F()
22c937
+     echo 'UndefFun()' UndefFun()
22c937
+ 
22c937
      redir END
22c937
  endfunction
22c937
  :call TestExists()
22c937
***************
22c937
*** 576,580 ****
22c937
--- 595,600 ----
22c937
  :set ff=unix
22c937
  :w
22c937
  :qa!
22c937
+ :while getchar(1) | call getchar() | endwhile
22c937
  ENDTEST
22c937
  
22c937
*** ../vim-7.4.148/src/testdir/test60.ok	2010-05-15 13:04:10.000000000 +0200
22c937
--- src/testdir/test60.ok	2014-01-14 14:50:50.000000000 +0100
22c937
***************
22c937
*** 71,76 ****
22c937
--- 71,80 ----
22c937
  OK
22c937
  *MyxyzFunc: 0
22c937
  OK
22c937
+ *UndefFun: 0
22c937
+ OK
22c937
+ *footest#F: 0
22c937
+ OK
22c937
  :edit: 2
22c937
  OK
22c937
  :edit/a: 0
22c937
***************
22c937
*** 95,100 ****
22c937
--- 99,106 ----
22c937
  OK
22c937
  local_var: 0
22c937
  OK
22c937
+ footest#x: 0
22c937
+ OK
22c937
  local_list: 1
22c937
  OK
22c937
  local_list[1]: 1
22c937
***************
22c937
*** 195,197 ****
22c937
--- 201,206 ----
22c937
  OK
22c937
  a:2: 0
22c937
  OK
22c937
+  g:footest#x = 1
22c937
+    footest#F() 0
22c937
+ UndefFun() 0
22c937
*** ../vim-7.4.148/src/testdir/sautest/autoload/footest.vim	1970-01-01 01:00:00.000000000 +0100
22c937
--- src/testdir/sautest/autoload/footest.vim	2014-01-14 14:52:06.000000000 +0100
22c937
***************
22c937
*** 0 ****
22c937
--- 1,5 ----
22c937
+ " Autoload script used by test55 and test60
22c937
+ let footest#x = 1
22c937
+ func footest#F()
22c937
+   return 0
22c937
+ endfunc
22c937
*** ../vim-7.4.148/src/version.c	2014-01-14 13:26:17.000000000 +0100
22c937
--- src/version.c	2014-01-14 15:23:36.000000000 +0100
22c937
***************
22c937
*** 740,741 ****
22c937
--- 740,743 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     149,
22c937
  /**/
22c937
22c937
-- 
22c937
hundred-and-one symptoms of being an internet addict:
22c937
157. You fum through a magazine, you first check to see if it has a web
22c937
     address.
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///