diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-26 13:00:49 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-26 13:00:49 +0200 |
commit | ce024c3e20839465dc8c8f79dcccc5414dd8c506 (patch) | |
tree | 4d19ec355f9da6c5b638662e195ead387a2e372a | |
parent | 444d878324525787e55185ce3c3e29a3de9b700a (diff) | |
download | vim-git-ce024c3e20839465dc8c8f79dcccc5414dd8c506.tar.gz |
patch 8.2.3052: Vim9: "legacy call" does not workv8.2.3052
Problem: Vim9: "legacy call" does not work.
Solution: Do not skip "call" after "legacy". (closes #8454)
-rw-r--r-- | src/testdir/test_vim9_func.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 42 |
3 files changed, 42 insertions, 19 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 301a55c87..bffbb1b0a 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -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', diff --git a/src/version.c b/src/version.c index 1270c0c06..2b320471b 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3052, +/**/ 3051, /**/ 3050, diff --git a/src/vim9compile.c b/src/vim9compile.c index dd3f3aec3..bb5ea9726 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -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; + } } /* @@ -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) |