]> granicus.if.org Git - vim/commitdiff
patch 8.2.2855: white space after "->" does not give E274 v8.2.2855
authorBram Moolenaar <Bram@vim.org>
Sat, 15 May 2021 18:06:58 +0000 (20:06 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 15 May 2021 18:06:58 +0000 (20:06 +0200)
Problem:    White space after "->" does not give E274.
Solution:   Do not skip white space in legacy script. (closes #8212)

src/eval.c
src/testdir/test_method.vim
src/version.c

index 0d4f5fe59c729c8edaa58dc0bb12539fa72f8f92..97c5f78dffaf50b2f72c2d49f8423f27a79d0b68 100644 (file)
@@ -5916,10 +5916,18 @@ handle_subscript(
        }
        else if (p[0] == '-' && p[1] == '>')
        {
-           *arg = skipwhite(p + 2);
+           if (in_vim9script())
+               *arg = skipwhite(p + 2);
+           else
+               *arg = p + 2;
            if (ret == OK)
            {
-               if ((**arg == '{' && !in_vim9script()) || **arg == '(')
+               if (VIM_ISWHITE(**arg))
+               {
+                   emsg(_(e_nowhitespace));
+                   ret = FAIL;
+               }
+               else if ((**arg == '{' && !in_vim9script()) || **arg == '(')
                    // expr->{lambda}() or expr->(lambda)()
                    ret = eval_lambda(arg, rettv, evalarg, verbose);
                else
index 262c08c79bd9e497ef5d87faae49058b2c740b77..6b62d36209920a8df4b4dd34681825f9f159ab27 100644 (file)
@@ -131,11 +131,12 @@ func Test_method_syntax()
   eval [1, 2, 3]  
        \ ->sort(
        \ )
-  eval [1, 2, 3]-> sort()
+  eval [1, 2, 3]->sort()
 
   call assert_fails('eval [1, 2, 3]->sort ()', 'E274:')
   call assert_fails('eval [1, 2, 3] ->sort ()', 'E274:')
   call assert_fails('eval [1, 2, 3]-> sort ()', 'E274:')
+  call assert_fails('eval [1, 2, 3]-> sort()', 'E274:')
 endfunc
 
 func Test_method_lambda()
index 7635c2f470f63e74e7f15020ba15b47b2fcf2d39..1aef3c7d3811d68b71fa803207edf60731ca8aa4 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2855,
 /**/
     2854,
 /**/