diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-08 21:10:01 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-08 21:10:01 +0200 |
commit | 5184132ec015f5889a3195d911e609d214f06bed (patch) | |
tree | 9b879ab9af52ed54b66511924dec640ecdecc559 | |
parent | 47ed553fd5bebfc36eb8aa81686eeaa5a84eccac (diff) | |
download | vim-git-5184132ec015f5889a3195d911e609d214f06bed.tar.gz |
patch 8.1.1828: not strict enough checking syntax of method invocationv8.1.1828
Problem: Not strict enough checking syntax of method invocation.
Solution: Check there is no white space inside ->method(.
-rw-r--r-- | runtime/doc/eval.txt | 15 | ||||
-rw-r--r-- | src/eval.c | 6 | ||||
-rw-r--r-- | src/testdir/test_method.vim | 10 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 29 insertions, 4 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 296b3a157..ca0779560 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -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 diff --git a/src/eval.c b/src/eval.c index caac2a1da..0f9c95fa0 100644 --- a/src/eval.c +++ b/src/eval.c @@ -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); } diff --git a/src/testdir/test_method.vim b/src/testdir/test_method.vim index 02c69f23e..7780f087d 100644 --- a/src/testdir/test_method.vim +++ b/src/testdir/test_method.vim @@ -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 diff --git a/src/version.c b/src/version.c index 4f8f152cd..9c6eccf3e 100644 --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1828, +/**/ 1827, /**/ 1826, |