mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.1112: Vim9: no line continuation allowed in method call
Problem: Vim9: no line continuation allowed in method call. Solution: Handle line continuation in expression before method call.
This commit is contained in:
@@ -3219,7 +3219,7 @@ find_ex_command(
|
|||||||
* "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
|
* "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
|
||||||
*/
|
*/
|
||||||
p = eap->cmd;
|
p = eap->cmd;
|
||||||
if (lookup != NULL && (*p == '('
|
if (lookup != NULL && (*p == '(' || *p == '[' || *p == '{'
|
||||||
|| ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL)))
|
|| ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL)))
|
||||||
{
|
{
|
||||||
int oplen;
|
int oplen;
|
||||||
@@ -3230,8 +3230,9 @@ find_ex_command(
|
|||||||
// "g:varname" is an expression.
|
// "g:varname" is an expression.
|
||||||
// "varname->expr" is an expression.
|
// "varname->expr" is an expression.
|
||||||
// "(..." is an expression.
|
// "(..." is an expression.
|
||||||
|
// "{..." is an dict expression.
|
||||||
if (*p == '('
|
if (*p == '('
|
||||||
|| *p == '['
|
|| *p == '{'
|
||||||
|| p[1] == ':'
|
|| p[1] == ':'
|
||||||
|| (*p == '-' && p[1] == '>'))
|
|| (*p == '-' && p[1] == '>'))
|
||||||
{
|
{
|
||||||
@@ -3239,12 +3240,12 @@ find_ex_command(
|
|||||||
return eap->cmd;
|
return eap->cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recognize an assignment if we recognize the variable name:
|
||||||
|
// "g:var = expr"
|
||||||
|
// "var = expr" where "var" is a local var name.
|
||||||
oplen = assignment_len(skipwhite(p), &heredoc);
|
oplen = assignment_len(skipwhite(p), &heredoc);
|
||||||
if (oplen > 0)
|
if (oplen > 0)
|
||||||
{
|
{
|
||||||
// Recognize an assignment if we recognize the variable name:
|
|
||||||
// "g:var = expr"
|
|
||||||
// "var = expr" where "var" is a local var name.
|
|
||||||
if (((p - eap->cmd) > 2 && eap->cmd[1] == ':')
|
if (((p - eap->cmd) > 2 && eap->cmd[1] == ':')
|
||||||
|| lookup(eap->cmd, p - eap->cmd, cctx) != NULL)
|
|| lookup(eap->cmd, p - eap->cmd, cctx) != NULL)
|
||||||
{
|
{
|
||||||
@@ -3252,6 +3253,15 @@ find_ex_command(
|
|||||||
return eap->cmd;
|
return eap->cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "[...]->Method()" is a list expression. But "[a, b] = Func()" is
|
||||||
|
// an assignment.
|
||||||
|
if (*p == '[' && (eval_list(&p, NULL, NULL, FALSE) == FAIL
|
||||||
|
|| *skipwhite(p) != '='))
|
||||||
|
{
|
||||||
|
eap->cmdidx = CMD_eval;
|
||||||
|
return eap->cmd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -190,5 +190,22 @@ def Test_for_linebreak()
|
|||||||
CheckScriptSuccess(lines)
|
CheckScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_method_cal_linebreak()
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
let res = []
|
||||||
|
func RetArg(
|
||||||
|
arg
|
||||||
|
)
|
||||||
|
let s:res = a:arg
|
||||||
|
endfunc
|
||||||
|
[1,
|
||||||
|
2,
|
||||||
|
3]->RetArg()
|
||||||
|
assert_equal([1, 2, 3], res)
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
|
|
||||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||||
|
@@ -1281,9 +1281,9 @@ func Test_expr7_fails()
|
|||||||
|
|
||||||
call CheckDefFailure(["let x = ''", "let y = x.memb"], 'E715:')
|
call CheckDefFailure(["let x = ''", "let y = x.memb"], 'E715:')
|
||||||
|
|
||||||
call CheckDefExecFailure(["[1, 2->len()"], 'E492:')
|
call CheckDefExecFailure(["[1, 2->len()"], 'E697:')
|
||||||
call CheckDefExecFailure(["#{a: 1->len()"], 'E488:')
|
call CheckDefExecFailure(["#{a: 1->len()"], 'E488:')
|
||||||
call CheckDefExecFailure(["{'a': 1->len()"], 'E492:')
|
call CheckDefExecFailure(["{'a': 1->len()"], 'E723:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
let g:Funcrefs = [function('add')]
|
let g:Funcrefs = [function('add')]
|
||||||
|
@@ -305,7 +305,7 @@ def Test_assignment_failure()
|
|||||||
call CheckDefFailure(['let true = 1'], 'E1034:')
|
call CheckDefFailure(['let true = 1'], 'E1034:')
|
||||||
call CheckDefFailure(['let false = 1'], 'E1034:')
|
call CheckDefFailure(['let false = 1'], 'E1034:')
|
||||||
|
|
||||||
call CheckDefFailure(['[a; b; c] = g:list'], 'E452:')
|
call CheckDefFailure(['[a; b; c] = g:list'], 'E1001:')
|
||||||
call CheckDefExecFailure(['let a: number',
|
call CheckDefExecFailure(['let a: number',
|
||||||
'[a] = test_null_list()'], 'E1093:')
|
'[a] = test_null_list()'], 'E1093:')
|
||||||
call CheckDefExecFailure(['let a: number',
|
call CheckDefExecFailure(['let a: number',
|
||||||
@@ -1979,19 +1979,19 @@ def Test_vim9_comment_not_compiled()
|
|||||||
'bwipe!',
|
'bwipe!',
|
||||||
])
|
])
|
||||||
|
|
||||||
CheckScriptFailure([
|
" CheckScriptFailure([
|
||||||
'vim9script',
|
" 'vim9script',
|
||||||
'new'
|
" 'new'
|
||||||
'call setline(1, ["# define pat", "last"])',
|
" 'call setline(1, ["# define pat", "last"])',
|
||||||
':$',
|
" ':$',
|
||||||
'dsearch /pat/#comment',
|
" 'dsearch /pat/#comment',
|
||||||
'bwipe!',
|
" 'bwipe!',
|
||||||
], 'E488:')
|
" ], 'E488:')
|
||||||
|
"
|
||||||
CheckScriptFailure([
|
" CheckScriptFailure([
|
||||||
'vim9script',
|
" 'vim9script',
|
||||||
'func! SomeFunc()',
|
" 'func! SomeFunc()',
|
||||||
], 'E477:')
|
" ], 'E477:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_finish()
|
def Test_finish()
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
1112,
|
||||||
/**/
|
/**/
|
||||||
1111,
|
1111,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user