mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.1.1828: not strict enough checking syntax of method invocation
Problem: Not strict enough checking syntax of method invocation. Solution: Check there is no white space inside ->method(.
This commit is contained in:
@@ -1223,12 +1223,19 @@ For methods that are also available as global functions this is the same as: >
|
|||||||
name(expr8 [, args])
|
name(expr8 [, args])
|
||||||
There can also be methods specifically for the type of "expr8".
|
There can also be methods specifically for the type of "expr8".
|
||||||
|
|
||||||
"->name(" must not contain white space. There can be white space before "->"
|
This allows for chaining, passing the value that one method returns to the
|
||||||
and after the "(".
|
next method: >
|
||||||
|
|
||||||
This allows for chaining, using the type that the method returns: >
|
|
||||||
mylist->filter(filterexpr)->map(mapexpr)->sort()->join()
|
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*
|
*expr9*
|
||||||
number
|
number
|
||||||
|
@@ -4862,6 +4862,12 @@ eval_method(
|
|||||||
semsg(_(e_missingparen), name);
|
semsg(_(e_missingparen), name);
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
}
|
}
|
||||||
|
else if (VIM_ISWHITE((*arg)[-1]))
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
semsg(_("E274: No white space allowed before parenthesis"));
|
||||||
|
ret = FAIL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ret = eval_func(arg, name, len, rettv, evaluate, &base);
|
ret = eval_func(arg, name, len, rettv, evaluate, &base);
|
||||||
}
|
}
|
||||||
|
@@ -112,3 +112,13 @@ func Test_method_funcref()
|
|||||||
|
|
||||||
delfunc Concat
|
delfunc Concat
|
||||||
endfunc
|
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
|
||||||
|
@@ -769,6 +769,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1828,
|
||||||
/**/
|
/**/
|
||||||
1827,
|
1827,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user