]> granicus.if.org Git - vim/commitdiff
patch 8.1.1828: not strict enough checking syntax of method invocation v8.1.1828
authorBram Moolenaar <Bram@vim.org>
Thu, 8 Aug 2019 19:10:01 +0000 (21:10 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 8 Aug 2019 19:10:01 +0000 (21:10 +0200)
Problem:    Not strict enough checking syntax of method invocation.
Solution:   Check there is no white space inside ->method(.

runtime/doc/eval.txt
src/eval.c
src/testdir/test_method.vim
src/version.c

index 296b3a157a0d5cd194a84af27c38f4f0c25fcdca..ca0779560f8164ffd2c2d73e358395c5918f09ae 100644 (file)
@@ -1223,12 +1223,19 @@ For methods that are also available as global functions this is the same as: >
        name(expr8 [, args])
 There can also be methods specifically for the type of "expr8".
 
-"->name(" must not contain white space.  There can be white space before "->"
-and after the "(".
-
-This allows for chaining, using the type that the method returns: >
+This allows for chaining, passing the value that one method returns to the
+next method: >
        mylist->filter(filterexpr)->map(mapexpr)->sort()->join()
 <
+                                                       *E274*
+"->name(" must not contain white space.  There can be white space before the
+"->" and after the "(", thus you can split the lines like this: >
+       mylist
+       \ ->filter(filterexpr)
+       \ ->map(mapexpr)
+       \ ->sort()
+       \ ->join()
+<
 
                                                        *expr9*
 number
index caac2a1da2c1fae6c0bdc7557ff83216fcf9ef6c..0f9c95fa0d876afbc85e4f03c0685bb88582ad9b 100644 (file)
@@ -4862,6 +4862,12 @@ eval_method(
                semsg(_(e_missingparen), name);
            ret = FAIL;
        }
+       else if (VIM_ISWHITE((*arg)[-1]))
+       {
+           if (verbose)
+               semsg(_("E274: No white space allowed before parenthesis"));
+           ret = FAIL;
+       }
        else
            ret = eval_func(arg, name, len, rettv, evaluate, &base);
     }
index 02c69f23eaf7d3b9c9a22f1142b4a3e668ab9a27..7780f087d4f5e404e86efc9251291c9397c6d01a 100644 (file)
@@ -112,3 +112,13 @@ func Test_method_funcref()
 
   delfunc Concat
 endfunc
+
+func Test_method_syntax()
+  eval [1, 2, 3]  ->sort( )
+  eval [1, 2, 3]  
+       \ ->sort(
+       \ )
+  call assert_fails('eval [1, 2, 3]-> sort()', 'E260:')
+  call assert_fails('eval [1, 2, 3]->sort ()', 'E274:')
+  call assert_fails('eval [1, 2, 3]-> sort ()', 'E260:')
+endfunc
index 4f8f152cd820cf69836886bfb0343da2d0732906..9c6eccf3e06efdfdc867c045acd2623f7f9e9f60 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1828,
 /**/
     1827,
 /**/