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