]> granicus.if.org Git - vim/commitdiff
patch 8.2.2964: Vim9: hang when using space after -> v8.2.2964
authorBram Moolenaar <Bram@vim.org>
Tue, 8 Jun 2021 18:46:45 +0000 (20:46 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 8 Jun 2021 18:46:45 +0000 (20:46 +0200)
Problem:    Vim9: hang when using space after ->. (Naohiro Ono)
Solution:   Skip over white space to find the function name. (closes #8341)

src/eval.c
src/testdir/test_vim9_expr.vim
src/version.c
src/vim9compile.c

index d0007bbd3e9684a2d52a0b8f3e3a1670693733f1..46d8ca3a82d71d624b92b73c216c1fe16d2267e0 100644 (file)
@@ -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;
index dc6858fc78286cca2a29cc4aae840e4d9e76b217..6b51bc78a509a30dc98e408f5a0be8ee2d7a84f6 100644 (file)
@@ -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
index cea97e8c5ef8b792d26b179ced2a1fec35f430ac..de03654afaab478f9514899800994f570648cadf 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2964,
 /**/
     2963,
 /**/
index 1256bfaac4603be0f4b894ebc252f345697a36fe..28108bfe7d1089e6a8299d04177c9a728afc5fa2 100644 (file)
@@ -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);