0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

updated for version 7.4.086

Problem:    Skipping over an expression when not evaluating it does not work
            properly for dict members.
Solution:   Skip over unrecognized expression. (ZyX)
This commit is contained in:
Bram Moolenaar
2013-11-11 04:25:53 +01:00
parent 3f75e422be
commit 0f8de8dfb2
4 changed files with 28 additions and 7 deletions

View File

@@ -19845,23 +19845,29 @@ handle_subscript(arg, rettv, evaluate, verbose)
while (ret == OK while (ret == OK
&& (**arg == '[' && (**arg == '['
|| (**arg == '.' && rettv->v_type == VAR_DICT) || (**arg == '.' && rettv->v_type == VAR_DICT)
|| (**arg == '(' && rettv->v_type == VAR_FUNC)) || (**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC)))
&& !vim_iswhite(*(*arg - 1))) && !vim_iswhite(*(*arg - 1)))
{ {
if (**arg == '(') if (**arg == '(')
{ {
/* need to copy the funcref so that we can clear rettv */ /* need to copy the funcref so that we can clear rettv */
if (evaluate)
{
functv = *rettv; functv = *rettv;
rettv->v_type = VAR_UNKNOWN; rettv->v_type = VAR_UNKNOWN;
/* Invoke the function. Recursive! */ /* Invoke the function. Recursive! */
s = functv.vval.v_string; s = functv.vval.v_string;
}
else
s = (char_u *)"";
ret = get_func_tv(s, (int)STRLEN(s), rettv, arg, ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
curwin->w_cursor.lnum, curwin->w_cursor.lnum, curwin->w_cursor.lnum, curwin->w_cursor.lnum,
&len, evaluate, selfdict); &len, evaluate, selfdict);
/* Clear the funcref afterwards, so that deleting it while /* Clear the funcref afterwards, so that deleting it while
* evaluating the arguments is possible (see test55). */ * evaluating the arguments is possible (see test55). */
if (evaluate)
clear_tv(&functv); clear_tv(&functv);
/* Stop the expression evaluation when immediately aborting on /* Stop the expression evaluation when immediately aborting on

View File

@@ -1,6 +1,7 @@
Test for user functions. Test for user functions.
Also test an <expr> mapping calling a function. Also test an <expr> mapping calling a function.
Also test that a builtin function cannot be replaced. Also test that a builtin function cannot be replaced.
Also test for regression when calling arbitrary expression.
STARTTEST STARTTEST
:so small.vim :so small.vim
@@ -62,7 +63,17 @@ XX+-XX
[(one again:call append(line('$'), max([1, 2, 3])) [(one again:call append(line('$'), max([1, 2, 3]))
:call extend(g:, {'max': function('min')}) :call extend(g:, {'max': function('min')})
:call append(line('$'), max([1, 2, 3])) :call append(line('$'), max([1, 2, 3]))
:$-7,$w! test.out :try
: " Regression: the first line below used to throw ?E110: Missing ')'?
: " Second is here just to prove that this line is correct when not skipping
: " rhs of &&.
: $put =(0&&(function('tr'))(1, 2, 3))
: $put =(1&&(function('tr'))(1, 2, 3))
:catch
: $put ='!!! Unexpected exception:'
: $put =v:exception
:endtry
:$-9,$w! test.out
:delfunc Table :delfunc Table
:delfunc Compute :delfunc Compute
:delfunc Expr1 :delfunc Expr1

View File

@@ -6,3 +6,5 @@ XX111-XX
1. one again 1. one again
3 3
3 3
0
1

View File

@@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
86,
/**/ /**/
85, 85,
/**/ /**/