Hi Bram!
On Do, 22 Nov 2012, Bram Moolenaar wrote:
>
> Andy Wokula wrote:
>
> > " Vim Parsing Bug
> >
> > func! Add2(x1, x2)
> > return a:x1 + a:x2
> > endfunc
> >
> > :echo function('Add2')(2,3)
> > " 5 (ok)
> >
> > " Bug:
> > :echo 1 ? function('Add2')(1,2) : function('Add2')(2,3)
> > :echo 0 ? function('Add2')(1,2) : function('Add2')(2,3)
> >
> > " Error detected while processing D1223.vim:
> > " line 17:
> > " E110: Missing ')'
> > " E15: Invalid expression: (2,3)
> > " line 18:
> > " E109: Missing ':' after '?'
> > " E15: Invalid expression: 0 ? function('Add2')(1,2) : function('Add2')(2,3)
> >
> >
> > Adding parentheses 1 ? (...) : (...) doesn't help.
>
> Strange. I'll add it to the todo list.
Problem is, in expr1 ? expr2 : expr3
Vim explicitly resets evaluate in the false case which leads to being
rettv.v_type being VAR_UNKNOWN and then handle_subscript doesn't handle
the subscript anymore.
Here is a patch:
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -19574,7 +19574,7 @@
while (ret == OK
&& (**arg == '['
|| (**arg == '.' && rettv->v_type == VAR_DICT)
- || (**arg == '(' && rettv->v_type == VAR_FUNC))
+ || (**arg == '(' && (rettv->v_type == VAR_FUNC || rettv->v_type == VAR_UNKNOWN)))
&& !vim_iswhite(*(*arg - 1)))
{
if (**arg == '(')
regards,
Christian
--
Niemand ist so gut oder so schlecht, wie er w�hrend seiner Scheidung
gemacht wird.
-- J.J. Disenberg