diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-04-25 13:54:42 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-04-25 13:54:42 +0200 |
commit | dc4c2309f2af347068edd60548269018f476dab9 (patch) | |
tree | 7a2daa30f2b5c2171b5f470688c6ceb87ae271d1 | |
parent | 730bf300202d82eff575581abc915b804275f18d (diff) | |
download | vim-git-dc4c2309f2af347068edd60548269018f476dab9.tar.gz |
patch 8.2.2809: Vim9: :def function compilation fails when using :legacyv8.2.2809
Problem: Vim9: :def function compilation fails when using :legacy.
Solution: Reset CMOD_LEGACY when compiling a function. (closes #8137)
-rw-r--r-- | src/testdir/test_vim9_func.vim | 10 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 5 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 230de20e3..5bfad6bcb 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -2167,10 +2167,20 @@ enddef def Test_legacy_lambda() legacy echo {x -> 'hello ' .. x}('foo') + var lines =<< trim END echo {x -> 'hello ' .. x}('foo') END CheckDefAndScriptFailure(lines, 'E720:') + + lines =<< trim END + vim9script + def Func() + echo (() => 'no error')() + enddef + legacy call s:Func() + END + CheckScriptSuccess(lines) enddef def DoFilterThis(a: string): list<string> diff --git a/src/version.c b/src/version.c index 4b0b1cc30..d235e94eb 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2809, +/**/ 2808, /**/ 2807, diff --git a/src/vim9compile.c b/src/vim9compile.c index a3154c331..8589cec60 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -8767,6 +8767,7 @@ compile_def_function( int ret = FAIL; sctx_T save_current_sctx = current_sctx; int save_estack_compiling = estack_compiling; + int save_cmod_flags = cmdmod.cmod_flags; int do_estack_push; int new_def_function = FALSE; #ifdef FEAT_PROFILE @@ -8811,6 +8812,9 @@ compile_def_function( current_sctx = ufunc->uf_script_ctx; current_sctx.sc_version = SCRIPT_VERSION_VIM9; + // Don't use the flag from ":legacy" here. + cmdmod.cmod_flags &= ~CMOD_LEGACY; + // Make sure error messages are OK. do_estack_push = !estack_top_is_ufunc(ufunc, 1); if (do_estack_push) @@ -9403,6 +9407,7 @@ erret: current_sctx = save_current_sctx; estack_compiling = save_estack_compiling; + cmdmod.cmod_flags = save_cmod_flags; if (do_estack_push) estack_pop(); |