Skip to content

Commit fb3d6aa

Browse files
committed
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)
1 parent 9910d54 commit fb3d6aa

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

src/eval.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19845,24 +19845,30 @@ handle_subscript(arg, rettv, evaluate, verbose)
1984519845
while (ret == OK
1984619846
&& (**arg == '['
1984719847
|| (**arg == '.' && rettv->v_type == VAR_DICT)
19848-
|| (**arg == '(' && rettv->v_type == VAR_FUNC))
19848+
|| (**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC)))
1984919849
&& !vim_iswhite(*(*arg - 1)))
1985019850
{
1985119851
if (**arg == '(')
1985219852
{
1985319853
/* need to copy the funcref so that we can clear rettv */
19854-
functv = *rettv;
19855-
rettv->v_type = VAR_UNKNOWN;
19854+
if (evaluate)
19855+
{
19856+
functv = *rettv;
19857+
rettv->v_type = VAR_UNKNOWN;
1985619858

19857-
/* Invoke the function. Recursive! */
19858-
s = functv.vval.v_string;
19859+
/* Invoke the function. Recursive! */
19860+
s = functv.vval.v_string;
19861+
}
19862+
else
19863+
s = (char_u *)"";
1985919864
ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
1986019865
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
1986119866
&len, evaluate, selfdict);
1986219867

1986319868
/* Clear the funcref afterwards, so that deleting it while
1986419869
* evaluating the arguments is possible (see test55). */
19865-
clear_tv(&functv);
19870+
if (evaluate)
19871+
clear_tv(&functv);
1986619872

1986719873
/* Stop the expression evaluation when immediately aborting on
1986819874
* error, or when an interrupt occurred or an exception was thrown

src/testdir/test34.in

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Test for user functions.
22
Also test an <expr> mapping calling a function.
33
Also test that a builtin function cannot be replaced.
4+
Also test for regression when calling arbitrary expression.
45

56
STARTTEST
67
:so small.vim
@@ -62,7 +63,17 @@ XX+-XX
6263
[(one again:call append(line('$'), max([1, 2, 3]))
6364
:call extend(g:, {'max': function('min')})
6465
:call append(line('$'), max([1, 2, 3]))
65-
:$-7,$w! test.out
66+
:try
67+
: " Regression: the first line below used to throw ?E110: Missing ')'?
68+
: " Second is here just to prove that this line is correct when not skipping
69+
: " rhs of &&.
70+
: $put =(0&&(function('tr'))(1, 2, 3))
71+
: $put =(1&&(function('tr'))(1, 2, 3))
72+
:catch
73+
: $put ='!!! Unexpected exception:'
74+
: $put =v:exception
75+
:endtry
76+
:$-9,$w! test.out
6677
:delfunc Table
6778
:delfunc Compute
6879
:delfunc Expr1

src/testdir/test34.ok

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ XX111-XX
66
1. one again
77
3
88
3
9+
0
10+
1

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
86,
741743
/**/
742744
85,
743745
/**/

0 commit comments

Comments
 (0)