Re: E685: Internal error: hash_add() happen when assigning autoload variable

2014-01-06 Fir de Conversatie Yukihiro Nakadaira
On Sun, Jan 5, 2014 at 11:44 PM, Nikolay Pavlov zyx@gmail.com wrote:


 On Jan 1, 2014 9:47 AM, Yukihiro Nakadaira yukihiro.nakada...@gmail.com
 wrote:
 
  Steps to reproduce:
$ cat ~/.vim/autoload/Foo.vim
let Foo#x = 0
$ vim -u NONE -N
:let Foo#x = function('tr')
E685: Internal error: hash_add()
 
  eval.c:set_var()
- var_check_func_name()Foo.vim is loaded and Foo#x is created.
- hash_add()   error, because Foo#x is already exists.
 
  Please check the following patch.
 
  diff -r 2f856c7c1d43 src/eval.c
  --- a/src/eval.cSun Dec 15 10:02:33 2013 +0100
  +++ b/src/eval.cWed Jan 01 13:44:46 2014 +0900
  @@ -20718,6 +20718,8 @@
   char_u *name;/* points to start of variable name */
   intnew_var;  /* TRUE when creating the variable */
   {
  +int err;
  +
   if (!(vim_strchr((char_u *)wbs, name[0]) != NULL  name[1] ==
 ':')
!ASCII_ISUPPER((name[0] != NUL  name[1] == ':')
? name[2] : name[0]))
  @@ -20729,7 +20731,10 @@
   /* Don't allow hiding a function.  When v is not NULL we might be
* assigning another function to the same var, the type is checked
* below. */
  -if (new_var  function_exists(name))
  +no_autoload = TRUE;
  +err = new_var  function_exists(name);
  +no_autoload = FALSE;

 Are you sure that no_autoload variable may never be TRUE when callin this
 function?


Yes, I am.

-- 
Yukihiro Nakadaira - yukihiro.nakada...@gmail.com

-- 
-- 
You received this message from the vim_dev maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
vim_dev group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: E685: Internal error: hash_add() happen when assigning autoload variable

2014-01-06 Fir de Conversatie ZyX
 Yes, I am.

You should not be.

let d={}
echo exists('*d[extend(g:, {Foo#x: function(tr)})]')

. f_exists() sets no_autoload to TRUE, dict_extend() runs var_check_func_name() 
which you have modified setting it back to FALSE before f_exists ends. f_exists 
should by the way save no_autoload variable for the same reason: it may be 
called recursively.

-- 
-- 
You received this message from the vim_dev maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
vim_dev group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: E685: Internal error: hash_add() happen when assigning autoload variable

2014-01-06 Fir de Conversatie Yukihiro Nakadaira
On Tue, Jan 7, 2014 at 5:33 AM, ZyX zyx@gmail.com wrote:

  Yes, I am.

 You should not be.

 let d={}
 echo exists('*d[extend(g:, {Foo#x: function(tr)})]')

 . f_exists() sets no_autoload to TRUE, dict_extend() runs
 var_check_func_name() which you have modified setting it back to FALSE
 before f_exists ends. f_exists should by the way save no_autoload variable
 for the same reason: it may be called recursively.


Thank you for finding it out.  I didn't notice it.
Perhaps there is another problem that exists('x[y#z()]') doesn't trigger
autoload.

-- 
Yukihiro Nakadaira - yukihiro.nakada...@gmail.com

-- 
-- 
You received this message from the vim_dev maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
vim_dev group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: E685: Internal error: hash_add() happen when assigning autoload variable

2014-01-06 Fir de Conversatie ZyX
 Thank you for finding it out.  I didn't notice it.
 
 Perhaps there is another problem that exists('x[y#z()]') doesn't trigger 
 autoload.

There is. The very good probability of such bugs is one of the reasons why I 
did not even consider adding similar global in extended funcref patch when I 
encountered similar problems (and removed no_autoload from there once it got my 
attention).

-- 
-- 
You received this message from the vim_dev maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
vim_dev group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: E685: Internal error: hash_add() happen when assigning autoload variable

2014-01-06 Fir de Conversatie ZyX
 There is. The very good probability of such bugs is one of the reasons why I 
 did not even consider adding similar global in extended funcref patch when I 
 encountered similar problems (and removed no_autoload from there once it got 
 my attention).

This patch replaces global with arguments in flags passed to some functions.

Changed behavior: lockvar and islocked() no longer trigger script autoloading 
(except for evaluating nested expressions like 
islocked('not#autoloaded#dict[autoloaded#function()]')). Do not think anybody 
actually relied on this.

# HG changeset patch
# User ZyX kp-...@ya.ru
# Date 1389066029 -14400
#  Tue Jan 07 07:40:29 2014 +0400
# Branch remove-no_autoload-global
# Node ID 7b182c0bfaf563de5b977e8773c409fef2457297
# Parent  bc19475ed196b91bf1ecda2224d88a47b5b497bb
Replace no_autoload global with arguments and flags

diff -r bc19475ed196 -r 7b182c0bfaf5 src/eval.c
--- a/src/eval.cMon Jan 06 15:51:55 2014 +0100
+++ b/src/eval.cTue Jan 07 07:40:29 2014 +0400
@@ -125,9 +125,6 @@
  */
 static hashtab_T   compat_hashtab;
 
-/* When using exists() don't auto-load a script. */
-static int no_autoload = FALSE;
-
 /*
  * When recursively copying lists and dicts we need to remember which ones we
  * have done to avoid endless recursiveness.  This unique ID is used for that.
@@ -156,6 +153,14 @@
 /* Values for trans_function_name() argument: */
 #define TFN_INT1   /* internal function name OK */
 #define TFN_QUIET  2   /* no error messages */
+#define TFN_NO_AUTOLOAD4   /* do not use script autoloading */
+
+/* #define TFN_TO_GLVAL(flags) (flags(TFN_QUIET|TFN_NO_AUTOLOAD)) */
+#define TFN_TO_GLV(flags)  (flags)
+
+/* Values for get_lval() flags argument: */
+#define GLV_QUIET  TFN_QUIET   /* no error messages */
+#define GLV_NO_AUTOLOADTFN_NO_AUTOLOAD /* do not use script 
autoloading */
 
 /*
  * Structure to hold info for a user function.
@@ -390,7 +395,7 @@
 static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg, int *first));
 static char_u *ex_let_one __ARGS((char_u *arg, typval_T *tv, int copy, char_u 
*endchars, char_u *op));
 static int check_changedtick __ARGS((char_u *arg));
-static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int 
unlet, int skip, int quiet, int fne_flags));
+static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int 
unlet, int skip, int flags, int fne_flags));
 static void clear_lval __ARGS((lval_T *lp));
 static void set_var_lval __ARGS((lval_T *lp, char_u *endp, typval_T *rettv, 
int copy, char_u *op));
 static int tv_op __ARGS((typval_T *tv1, typval_T *tv2, char_u  *op));
@@ -770,7 +775,7 @@
 static char_u * make_expanded_name __ARGS((char_u *in_start, char_u 
*expr_start, char_u *expr_end, char_u *in_end));
 static int eval_isnamec __ARGS((int c));
 static int eval_isnamec1 __ARGS((int c));
-static int get_var_tv __ARGS((char_u *name, int len, typval_T *rettv, int 
verbose));
+static int get_var_tv __ARGS((char_u *name, int len, typval_T *rettv, int 
verbose, int no_autoload));
 static int handle_subscript __ARGS((char_u **arg, typval_T *rettv, int 
evaluate, int verbose));
 static typval_T *alloc_tv __ARGS((void));
 static typval_T *alloc_string_tv __ARGS((char_u *string));
@@ -781,8 +786,8 @@
 static char_u *get_tv_string __ARGS((typval_T *varp));
 static char_u *get_tv_string_buf __ARGS((typval_T *varp, char_u *buf));
 static char_u *get_tv_string_buf_chk __ARGS((typval_T *varp, char_u *buf));
-static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp));
-static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, int htname, char_u 
*varname, int writing));
+static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp, int 
no_autoload));
+static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, int htname, char_u 
*varname, int no_autoload));
 static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname));
 static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val));
 static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi));
@@ -1059,7 +1064,7 @@
 ga_init2(redir_ga, (int)sizeof(char), 500);
 
 /* Parse the variable name (can be a dict or list entry). */
-redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, FALSE,
+redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, 0,
 FNE_CHECK_START);
 if (redir_endp == NULL || redir_lval-ll_name == NULL || *redir_endp != 
NUL)
 {
@@ -1150,7 +1155,7 @@
/* Call get_lval() again, if it's inside a Dict or List it may
 * have changed. */
redir_endp = get_lval(redir_varname, NULL, redir_lval,
-   FALSE, FALSE, FALSE, FNE_CHECK_START);
+   FALSE, FALSE, 0, FNE_CHECK_START);
if (redir_endp != NULL  

Re: E685: Internal error: hash_add() happen when assigning autoload variable

2014-01-05 Fir de Conversatie Bram Moolenaar

Yukihiro -

 Steps to reproduce:
   $ cat ~/.vim/autoload/Foo.vim
   let Foo#x = 0
   $ vim -u NONE -N
   :let Foo#x = function('tr')
   E685: Internal error: hash_add()
 
 eval.c:set_var()
   - var_check_func_name()Foo.vim is loaded and Foo#x is created.
   - hash_add()   error, because Foo#x is already exists.
 
 Please check the following patch.

Thanks, I'll check it out.

-- 
hundred-and-one symptoms of being an internet addict:
96. On Super Bowl Sunday, you followed the score by going to the
Yahoo main page instead of turning on the TV.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the vim_dev maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
vim_dev group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: E685: Internal error: hash_add() happen when assigning autoload variable

2014-01-05 Fir de Conversatie Nikolay Pavlov
On Jan 1, 2014 9:47 AM, Yukihiro Nakadaira yukihiro.nakada...@gmail.com
wrote:

 Steps to reproduce:
   $ cat ~/.vim/autoload/Foo.vim
   let Foo#x = 0
   $ vim -u NONE -N
   :let Foo#x = function('tr')
   E685: Internal error: hash_add()

 eval.c:set_var()
   - var_check_func_name()Foo.vim is loaded and Foo#x is created.
   - hash_add()   error, because Foo#x is already exists.

 Please check the following patch.

 diff -r 2f856c7c1d43 src/eval.c
 --- a/src/eval.cSun Dec 15 10:02:33 2013 +0100
 +++ b/src/eval.cWed Jan 01 13:44:46 2014 +0900
 @@ -20718,6 +20718,8 @@
  char_u *name;/* points to start of variable name */
  intnew_var;  /* TRUE when creating the variable */
  {
 +int err;
 +
  if (!(vim_strchr((char_u *)wbs, name[0]) != NULL  name[1] == ':')
   !ASCII_ISUPPER((name[0] != NUL  name[1] == ':')
   ? name[2] : name[0]))
 @@ -20729,7 +20731,10 @@
  /* Don't allow hiding a function.  When v is not NULL we might be
   * assigning another function to the same var, the type is checked
   * below. */
 -if (new_var  function_exists(name))
 +no_autoload = TRUE;
 +err = new_var  function_exists(name);
 +no_autoload = FALSE;

Are you sure that no_autoload variable may never be TRUE when callin this
function?

 +if (err)
  {
  EMSG2(_(E705: Variable name conflicts with existing function: %s),
  name);


 --
 Yukihiro Nakadaira - yukihiro.nakada...@gmail.com

 --
 --
 You received this message from the vim_dev maillist.
 Do not top-post! Type your reply below the text you are replying to.
 For more information, visit http://www.vim.org/maillist.php

 ---
 You received this message because you are subscribed to the Google Groups
vim_dev group.
 To unsubscribe from this group and stop receiving emails from it, send an
email to vim_dev+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
-- 
You received this message from the vim_dev maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
vim_dev group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.