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