Skip to content

Commit

Permalink
patch 8.2.3052: Vim9: "legacy call" does not work
Browse files Browse the repository at this point in the history
Problem:    Vim9: "legacy call" does not work.
Solution:   Do not skip "call" after "legacy". (closes #8454)
  • Loading branch information
brammool committed Jun 26, 2021
1 parent 444d878 commit ce024c3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 19 deletions.
17 changes: 17 additions & 0 deletions src/testdir/test_vim9_func.vim
Expand Up @@ -2316,6 +2316,23 @@ def Test_legacy_lambda()
CheckScriptSuccess(lines)
enddef

def Test_legacy()
var lines =<< trim END
vim9script
func g:LegacyFunction()
let g:legacyvar = 1
endfunc
def Testit()
legacy call g:LegacyFunction()
enddef
Testit()
assert_equal(1, g:legacyvar)
unlet g:legacyvar
delfunc g:LegacyFunction
END
CheckScriptSuccess(lines)
enddef

def Test_legacy_errors()
for cmd in ['if', 'elseif', 'else', 'endif',
'for', 'endfor', 'continue', 'break',
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -755,6 +755,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3052,
/**/
3051,
/**/
Expand Down
42 changes: 23 additions & 19 deletions src/vim9compile.c
Expand Up @@ -9346,27 +9346,30 @@ compile_def_function(
break;
}

// Skip ":call" to get to the function name.
// Skip ":call" to get to the function name, unless using :legacy
p = ea.cmd;
if (checkforcmd(&ea.cmd, "call", 3))
if (!(local_cmdmod.cmod_flags & CMOD_LEGACY))
{
if (*ea.cmd == '(')
// not for "call()"
ea.cmd = p;
else
ea.cmd = skipwhite(ea.cmd);
}
if (checkforcmd(&ea.cmd, "call", 3))
{
if (*ea.cmd == '(')
// not for "call()"
ea.cmd = p;
else
ea.cmd = skipwhite(ea.cmd);
}

if (!starts_with_colon)
{
int assign;
if (!starts_with_colon)
{
int assign;

// Check for assignment after command modifiers.
assign = may_compile_assignment(&ea, &line, &cctx);
if (assign == OK)
goto nextline;
if (assign == FAIL)
goto erret;
// Check for assignment after command modifiers.
assign = may_compile_assignment(&ea, &line, &cctx);
if (assign == OK)
goto nextline;
if (assign == FAIL)
goto erret;
}
}

/*
Expand All @@ -9375,8 +9378,9 @@ compile_def_function(
* "++nr" and "--nr" are eval commands
*/
cmd = ea.cmd;
if (starts_with_colon || !(*cmd == '\''
|| (cmd[0] == cmd[1] && (*cmd == '+' || *cmd == '-'))))
if (!(local_cmdmod.cmod_flags & CMOD_LEGACY)
&& (starts_with_colon || !(*cmd == '\''
|| (cmd[0] == cmd[1] && (*cmd == '+' || *cmd == '-')))))
{
ea.cmd = skip_range(ea.cmd, TRUE, NULL);
if (ea.cmd > cmd)
Expand Down

0 comments on commit ce024c3

Please sign in to comment.