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