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