3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.086
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.086
3ef2ca
Problem:    Skipping over an expression when not evaluating it does not work
3ef2ca
            properly for dict members.
3ef2ca
Solution:   Skip over unrecognized expression. (ZyX)
3ef2ca
Files:      src/eval.c, src/testdir/test34.in, src/testdir/test34.ok
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.085/src/eval.c	2013-11-08 04:30:06.000000000 +0100
3ef2ca
--- src/eval.c	2013-11-11 04:11:38.000000000 +0100
3ef2ca
***************
3ef2ca
*** 19845,19868 ****
3ef2ca
      while (ret == OK
3ef2ca
  	    && (**arg == '['
3ef2ca
  		|| (**arg == '.' && rettv->v_type == VAR_DICT)
3ef2ca
! 		|| (**arg == '(' && rettv->v_type == VAR_FUNC))
3ef2ca
  	    && !vim_iswhite(*(*arg - 1)))
3ef2ca
      {
3ef2ca
  	if (**arg == '(')
3ef2ca
  	{
3ef2ca
  	    /* need to copy the funcref so that we can clear rettv */
3ef2ca
! 	    functv = *rettv;
3ef2ca
! 	    rettv->v_type = VAR_UNKNOWN;
3ef2ca
  
3ef2ca
! 	    /* Invoke the function.  Recursive! */
3ef2ca
! 	    s = functv.vval.v_string;
3ef2ca
  	    ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
3ef2ca
  			curwin->w_cursor.lnum, curwin->w_cursor.lnum,
3ef2ca
  			&len, evaluate, selfdict);
3ef2ca
  
3ef2ca
  	    /* Clear the funcref afterwards, so that deleting it while
3ef2ca
  	     * evaluating the arguments is possible (see test55). */
3ef2ca
! 	    clear_tv(&functv);
3ef2ca
  
3ef2ca
  	    /* Stop the expression evaluation when immediately aborting on
3ef2ca
  	     * error, or when an interrupt occurred or an exception was thrown
3ef2ca
--- 19845,19874 ----
3ef2ca
      while (ret == OK
3ef2ca
  	    && (**arg == '['
3ef2ca
  		|| (**arg == '.' && rettv->v_type == VAR_DICT)
3ef2ca
! 		|| (**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC)))
3ef2ca
  	    && !vim_iswhite(*(*arg - 1)))
3ef2ca
      {
3ef2ca
  	if (**arg == '(')
3ef2ca
  	{
3ef2ca
  	    /* need to copy the funcref so that we can clear rettv */
3ef2ca
! 	    if (evaluate)
3ef2ca
! 	    {
3ef2ca
! 		functv = *rettv;
3ef2ca
! 		rettv->v_type = VAR_UNKNOWN;
3ef2ca
  
3ef2ca
! 		/* Invoke the function.  Recursive! */
3ef2ca
! 		s = functv.vval.v_string;
3ef2ca
! 	    }
3ef2ca
! 	    else
3ef2ca
! 		s = (char_u *)"";
3ef2ca
  	    ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
3ef2ca
  			curwin->w_cursor.lnum, curwin->w_cursor.lnum,
3ef2ca
  			&len, evaluate, selfdict);
3ef2ca
  
3ef2ca
  	    /* Clear the funcref afterwards, so that deleting it while
3ef2ca
  	     * evaluating the arguments is possible (see test55). */
3ef2ca
! 	    if (evaluate)
3ef2ca
! 		clear_tv(&functv);
3ef2ca
  
3ef2ca
  	    /* Stop the expression evaluation when immediately aborting on
3ef2ca
  	     * error, or when an interrupt occurred or an exception was thrown
3ef2ca
*** ../vim-7.4.085/src/testdir/test34.in	2012-07-16 16:51:29.000000000 +0200
3ef2ca
--- src/testdir/test34.in	2013-11-11 04:10:13.000000000 +0100
3ef2ca
***************
3ef2ca
*** 1,6 ****
3ef2ca
--- 1,7 ----
3ef2ca
  Test for user functions.
3ef2ca
  Also test an <expr> mapping calling a function.
3ef2ca
  Also test that a builtin function cannot be replaced.
3ef2ca
+ Also test for regression when calling arbitrary expression.
3ef2ca
  
3ef2ca
  STARTTEST
3ef2ca
  :so small.vim
3ef2ca
***************
3ef2ca
*** 62,68 ****
3ef2ca
  [(one again?:call append(line('$'), max([1, 2, 3]))
3ef2ca
  :call extend(g:, {'max': function('min')})
3ef2ca
  :call append(line('$'), max([1, 2, 3]))
3ef2ca
! :$-7,$w! test.out
3ef2ca
  :delfunc Table
3ef2ca
  :delfunc Compute
3ef2ca
  :delfunc Expr1
3ef2ca
--- 63,79 ----
3ef2ca
  [(one again?:call append(line('$'), max([1, 2, 3]))
3ef2ca
  :call extend(g:, {'max': function('min')})
3ef2ca
  :call append(line('$'), max([1, 2, 3]))
3ef2ca
! :try
3ef2ca
! :    " Regression: the first line below used to throw ?E110: Missing ')'?
3ef2ca
! :    " Second is here just to prove that this line is correct when not skipping
3ef2ca
! :    " rhs of &&.
3ef2ca
! :    $put =(0&&(function('tr'))(1, 2, 3))
3ef2ca
! :    $put =(1&&(function('tr'))(1, 2, 3))
3ef2ca
! :catch
3ef2ca
! :    $put ='!!! Unexpected exception:'
3ef2ca
! :    $put =v:exception
3ef2ca
! :endtry
3ef2ca
! :$-9,$w! test.out
3ef2ca
  :delfunc Table
3ef2ca
  :delfunc Compute
3ef2ca
  :delfunc Expr1
3ef2ca
*** ../vim-7.4.085/src/testdir/test34.ok	2012-07-16 16:43:15.000000000 +0200
3ef2ca
--- src/testdir/test34.ok	2013-11-11 04:10:13.000000000 +0100
3ef2ca
***************
3ef2ca
*** 6,8 ****
3ef2ca
--- 6,10 ----
3ef2ca
  1. one again
3ef2ca
  3
3ef2ca
  3
3ef2ca
+ 0
3ef2ca
+ 1
3ef2ca
*** ../vim-7.4.085/src/version.c	2013-11-11 01:29:16.000000000 +0100
3ef2ca
--- src/version.c	2013-11-11 04:15:59.000000000 +0100
3ef2ca
***************
3ef2ca
*** 740,741 ****
3ef2ca
--- 740,743 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     86,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
ARTHUR: The swallow may fly south with the sun, or the house martin or the
3ef2ca
        plover seek warmer hot lands in winter, yet these are not strangers to
3ef2ca
        our land.
3ef2ca
SOLDIER: Are you suggesting coconuts migrate?
3ef2ca
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///