/*
* Evaluate "->method()".
- * "*arg" points to the '-'.
+ * "*arg" points to "method".
* Returns FAIL or OK. "*arg" is advanced to after the ')'.
*/
static int
typval_T base = *rettv;
int ret;
- // Skip over the ->.
- *arg += 2;
rettv->v_type = VAR_UNKNOWN;
if (**arg == '{')
/*
* Evaluate "->method()".
- * "*arg" points to the '-'.
+ * "*arg" points to "method".
* Returns FAIL or OK. "*arg" is advanced to after the ')'.
*/
static int
int evaluate = evalarg != NULL
&& (evalarg->eval_flags & EVAL_EVALUATE);
- // Skip over the ->.
- *arg += 2;
rettv->v_type = VAR_UNKNOWN;
name = *arg;
}
else if (p[0] == '-' && p[1] == '>')
{
- *arg = p;
+ *arg = skipwhite(p + 2);
if (ret == OK)
{
- if (((*arg)[2] == '{' && !in_vim9script()) || (*arg)[2] == '(')
+ if ((**arg == '{' && !in_vim9script()) || **arg == '(')
// expr->{lambda}() or expr->(lambda)()
ret = eval_lambda(arg, rettv, evalarg, verbose);
else
if (vim_strchr((char_u *)"{('[\"@", *p) != NULL
|| ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
{
- int oplen;
- int heredoc;
+ int oplen;
+ int heredoc;
+ char_u *swp = skipwhite(p);
if (
// "(..." is an expression.
|| eap->cmd[1] == ':'
)
// "varname->func()" is an expression.
- : (*p == '-' && p[1] == '>')))
+ : (*swp == '-' && swp[1] == '>')))
{
if (*eap->cmd == '{' && ends_excmd(*skipwhite(eap->cmd + 1)))
{
CheckScriptSuccess(lines)
enddef
+def Test_method_call_whitespace()
+ var lines =<< trim END
+ new
+ var yank = 'text'
+ yank->setline(1)
+ yank ->setline(2)
+ yank-> setline(3)
+ yank -> setline(4)
+ assert_equal(['text', 'text', 'text', 'text'], getline(1, 4))
+ bwipe!
+ END
+ CheckDefAndScriptSuccess(lines)
+enddef
+
def Test_skipped_expr_linebreak()
if 0
var x = []