On Monday, October 14, 2013 11:40:48 PM UTC+4, ZyX wrote:
> Try the following code:
>
> vim -u NONE -N -c "echo (0 && (function('tr'))(1, 2, 3))"
>
> . This will throw “E110: Missing ')'” error while it should throw nothing
> (after changing 0 to 1 it works fine effectively showing that I have no
> errors on && right side). I guess we must just allow handle_subscript handle
> any kind of subscripts when skipping (disable checks for rettv->v_type): this
> should also solve problem with “dict.0key_that_starts_with_number”.
For expr7() such solution seem to work. For expr7.key this is not as simple: I
immediately found problems with dot used for string concatenation. Patch for
expr7(key) is attached.
Note: patch is known to pass all tests, but I have not checked it under
valgrind (seems to not introduce any problems). No tests yet: not sure where to
put it. Test is as simple as checking that `echo (0 && (function('tr'))(1, 2,
3))` echoes zero and no errors: output captured with `:redir` should contain
only a few newlines and a zero.
# 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
--
--
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.
*** /tmp/extdiff.WliWlJ/vim-small-patches.92c9748e0ccb/src/eval.c 2013-10-15 22:18:33.112676025 +0400
--- vim-small-patches.3f2e288daa4b/src/eval.c 2013-10-15 22:18:33.131675775 +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