Here is the updated patch:
# HG changeset patch
# User ZyX <[email protected]>
# Date 1381860915 -14400
# Tue Oct 15 22:15:15 2013 +0400
# Node ID 3f2e288daa4b92ea22139b213621e90b20f500f0
# Parent 92c9748e0ccbc42a5e28ce8fb9b8818e756a06da
When skipping allow any expression to pretend being a function
diff -r 92c9748e0ccb -r 3f2e288daa4b src/eval.c
--- a/src/eval.c Sun Oct 06 17:46:56 2013 +0200
+++ b/src/eval.c Tue Oct 15 22:15:15 2013 +0400
@@ -19817,24 +19817,30 @@
while (ret == OK
&& (**arg == '['
|| (**arg == '.' && rettv->v_type == VAR_DICT)
- || (**arg == '(' && rettv->v_type == VAR_FUNC))
+ || (**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC)))
&& !vim_iswhite(*(*arg - 1)))
{
if (**arg == '(')
{
/* need to copy the funcref so that we can clear rettv */
- functv = *rettv;
- rettv->v_type = VAR_UNKNOWN;
-
- /* Invoke the function. Recursive! */
- s = functv.vval.v_string;
+ if (evaluate)
+ {
+ functv = *rettv;
+ rettv->v_type = VAR_UNKNOWN;
+
+ /* Invoke the function. Recursive! */
+ s = functv.vval.v_string;
+ }
+ else
+ s = "";
ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
&len, evaluate, selfdict);
/* Clear the funcref afterwards, so that deleting it while
* evaluating the arguments is possible (see test55). */
- clear_tv(&functv);
+ if (evaluate)
+ clear_tv(&functv);
/* Stop the expression evaluation when immediately aborting on
* error, or when an interrupt occurred or an exception was thrown
# HG changeset patch
# User ZyX <[email protected]>
# Date 1382540204 -14400
# Wed Oct 23 18:56:44 2013 +0400
# Node ID 9573bf9b8634a5c7d315e7009e911fbe4577c847
# Parent 3f2e288daa4b92ea22139b213621e90b20f500f0
Add regression test
diff -r 3f2e288daa4b -r 9573bf9b8634 src/testdir/test34.in
--- a/src/testdir/test34.in Tue Oct 15 22:15:15 2013 +0400
+++ b/src/testdir/test34.in Wed Oct 23 18:56:44 2013 +0400
@@ -1,6 +1,7 @@
Test for user functions.
Also test an <expr> mapping calling a function.
Also test that a builtin function cannot be replaced.
+Also test for regression when calling arbitrary expression.
STARTTEST
:so small.vim
@@ -62,7 +63,17 @@
[(one again :call append(line('$'), max([1, 2, 3]))
:call extend(g:, {'max': function('min')})
: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 Compute
:delfunc Expr1
diff -r 3f2e288daa4b -r 9573bf9b8634 src/testdir/test34.ok
--- a/src/testdir/test34.ok Tue Oct 15 22:15:15 2013 +0400
+++ b/src/testdir/test34.ok Wed Oct 23 18:56:44 2013 +0400
@@ -6,3 +6,5 @@
1. one again
3
3
+0
+1
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff -crN vim-small-patches.92c9748e0ccb/src/eval.c vim-small-patches.9573bf9b8634/src/eval.c
*** vim-small-patches.92c9748e0ccb/src/eval.c 2013-10-23 18:58:16.125932732 +0400
--- vim-small-patches.9573bf9b8634/src/eval.c 2013-10-23 18:58:16.148932525 +0400
***************
*** 19817,19840 ****
while (ret == OK
&& (**arg == '['
|| (**arg == '.' && rettv->v_type == VAR_DICT)
! || (**arg == '(' && rettv->v_type == VAR_FUNC))
&& !vim_iswhite(*(*arg - 1)))
{
if (**arg == '(')
{
/* need to copy the funcref so that we can clear rettv */
! functv = *rettv;
! rettv->v_type = VAR_UNKNOWN;
! /* Invoke the function. Recursive! */
! s = functv.vval.v_string;
ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
&len, evaluate, selfdict);
/* Clear the funcref afterwards, so that deleting it while
* evaluating the arguments is possible (see test55). */
! clear_tv(&functv);
/* Stop the expression evaluation when immediately aborting on
* error, or when an interrupt occurred or an exception was thrown
--- 19817,19846 ----
while (ret == OK
&& (**arg == '['
|| (**arg == '.' && rettv->v_type == VAR_DICT)
! || (**arg == '(' && (!evaluate || rettv->v_type == VAR_FUNC)))
&& !vim_iswhite(*(*arg - 1)))
{
if (**arg == '(')
{
/* need to copy the funcref so that we can clear rettv */
! if (evaluate)
! {
! functv = *rettv;
! rettv->v_type = VAR_UNKNOWN;
! /* Invoke the function. Recursive! */
! s = functv.vval.v_string;
! }
! else
! s = "";
ret = get_func_tv(s, (int)STRLEN(s), rettv, arg,
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
&len, evaluate, selfdict);
/* Clear the funcref afterwards, so that deleting it while
* evaluating the arguments is possible (see test55). */
! if (evaluate)
! clear_tv(&functv);
/* Stop the expression evaluation when immediately aborting on
* error, or when an interrupt occurred or an exception was thrown
diff -crN vim-small-patches.92c9748e0ccb/src/testdir/test34.in vim-small-patches.9573bf9b8634/src/testdir/test34.in
*** vim-small-patches.92c9748e0ccb/src/testdir/test34.in 2013-10-23 18:58:16.102932939 +0400
--- vim-small-patches.9573bf9b8634/src/testdir/test34.in 2013-10-23 18:58:16.126932723 +0400
***************
*** 1,6 ****
--- 1,7 ----
Test for user functions.
Also test an <expr> mapping calling a function.
Also test that a builtin function cannot be replaced.
+ Also test for regression when calling arbitrary expression.
STARTTEST
:so small.vim
***************
*** 62,68 ****
[(one again:call append(line('$'), max([1, 2, 3]))
:call extend(g:, {'max': function('min')})
:call append(line('$'), max([1, 2, 3]))
! :$-7,$w! test.out
:delfunc Table
:delfunc Compute
:delfunc Expr1
--- 63,79 ----
[(one again:call append(line('$'), max([1, 2, 3]))
:call extend(g:, {'max': function('min')})
:call append(line('$'), max([1, 2, 3]))
! :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 Compute
:delfunc Expr1
diff -crN vim-small-patches.92c9748e0ccb/src/testdir/test34.ok vim-small-patches.9573bf9b8634/src/testdir/test34.ok
*** vim-small-patches.92c9748e0ccb/src/testdir/test34.ok 2013-10-23 18:58:16.102932939 +0400
--- vim-small-patches.9573bf9b8634/src/testdir/test34.ok 2013-10-23 18:58:16.126932723 +0400
***************
*** 6,8 ****
--- 6,10 ----
1. one again
3
3
+ 0
+ 1