summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-06-08 20:46:45 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-08 20:46:45 +0200
commita733042b124357225e4081e10ef28591236c6077 (patch)
treefefeb31a61e32faff8552fc30f32dd2422c15417
parent445f11d5bcfddfa194ebd12b029228c7e957f94c (diff)
patch 8.2.2964: Vim9: hang when using space after ->v8.2.2964
Problem: Vim9: hang when using space after ->. (Naohiro Ono) Solution: Skip over white space to find the function name. (closes #8341)
-rw-r--r--src/eval.c5
-rw-r--r--src/testdir/test_vim9_expr.vim4
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c3
4 files changed, 11 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c
index d0007bbd3e..46d8ca3a82 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -5786,8 +5786,9 @@ handle_subscript(
p = eval_next_non_blank(*arg, evalarg, &getnext);
if (getnext
&& ((rettv->v_type == VAR_DICT && *p == '.' && eval_isdictc(p[1]))
- || (p[0] == '-' && p[1] == '>'
- && (p[2] == '{' || ASCII_ISALPHA(p[2])))))
+ || (p[0] == '-' && p[1] == '>' && (p[2] == '{'
+ || ASCII_ISALPHA(in_vim9script() ? *skipwhite(p + 2)
+ : p[2])))))
{
*arg = eval_next_line(evalarg);
p = *arg;
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index dc6858fc78..6b51bc78a5 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -2961,6 +2961,10 @@ def Test_expr7_method_call()
var Join = (l) => join(l, 'x')
assert_equal('axb', ['a', 'b']->(Join)())
+
+ var sorted = [3, 1, 2]
+ -> sort()
+ assert_equal([1, 2, 3], sorted)
END
CheckDefAndScriptSuccess(lines)
enddef
diff --git a/src/version.c b/src/version.c
index cea97e8c5e..de03654afa 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 */
/**/
+ 2964,
+/**/
2963,
/**/
2962,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 1256bfaac4..28108bfe7d 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -4108,7 +4108,8 @@ compile_subscript(
// Also if a following line starts with ".x".
if (next != NULL &&
((next[0] == '-' && next[1] == '>'
- && (next[2] == '{' || ASCII_ISALPHA(next[2])))
+ && (next[2] == '{'
+ || ASCII_ISALPHA(*skipwhite(next + 2))))
|| (next[0] == '.' && eval_isdictc(next[1]))))
{
next = next_line_from_context(cctx, TRUE);