summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-01-23 14:22:16 +0100
committerBram Moolenaar <Bram@vim.org>2021-01-23 14:22:16 +0100
commit7cebe8ba7dd9a3a955e2da74014f11c42e1c6ac3 (patch)
tree5ae0e69fe4197c75c29d673b41d4b8b6b68eef0e
parent9a562c184d98d82bb7506caf2071cfe15a92fa43 (diff)
patch 8.2.2396: Vim9: no white space allowed before "->"v8.2.2396
Problem: Vim9: no white space allowed before "->". Solution: Allow for white space. (closes #7725)
-rw-r--r--src/eval.c12
-rw-r--r--src/ex_docmd.c7
-rw-r--r--src/testdir/test_vim9_cmd.vim14
-rw-r--r--src/version.c2
4 files changed, 24 insertions, 11 deletions
diff --git a/src/eval.c b/src/eval.c
index 3e316bdb10..ebd25077c3 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3671,7 +3671,7 @@ call_func_rettv(
/*
* Evaluate "->method()".
- * "*arg" points to the '-'.
+ * "*arg" points to "method".
* Returns FAIL or OK. "*arg" is advanced to after the ')'.
*/
static int
@@ -3686,8 +3686,6 @@ eval_lambda(
typval_T base = *rettv;
int ret;
- // Skip over the ->.
- *arg += 2;
rettv->v_type = VAR_UNKNOWN;
if (**arg == '{')
@@ -3735,7 +3733,7 @@ eval_lambda(
/*
* Evaluate "->method()".
- * "*arg" points to the '-'.
+ * "*arg" points to "method".
* Returns FAIL or OK. "*arg" is advanced to after the ')'.
*/
static int
@@ -3753,8 +3751,6 @@ eval_method(
int evaluate = evalarg != NULL
&& (evalarg->eval_flags & EVAL_EVALUATE);
- // Skip over the ->.
- *arg += 2;
rettv->v_type = VAR_UNKNOWN;
name = *arg;
@@ -5765,10 +5761,10 @@ handle_subscript(
}
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
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 9562e6be3a..b9ae13d0a8 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3313,8 +3313,9 @@ find_ex_command(
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.
@@ -3332,7 +3333,7 @@ find_ex_command(
|| eap->cmd[1] == ':'
)
// "varname->func()" is an expression.
- : (*p == '-' && p[1] == '>')))
+ : (*swp == '-' && swp[1] == '>')))
{
if (*eap->cmd == '{' && ends_excmd(*skipwhite(eap->cmd + 1)))
{
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index 12b9bf191b..735f48807d 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -319,6 +319,20 @@ def Test_method_call_linebreak()
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 = []
diff --git a/src/version.c b/src/version.c
index 7942e743f2..af1f7d2959 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2396,
+/**/
2395,
/**/
2394,