0
0
mirror of https://github.com/vim/vim.git synced 2025-10-01 04:54:07 -04:00

patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file

Problem:    Vim9: Not possible to use legacy and Vim9 script in one file.
Solution:   Vim9: allow for "if false" before :vim9script. (closes #7851)
This commit is contained in:
Bram Moolenaar
2021-02-17 21:57:03 +01:00
parent c7dac8534e
commit d3f8a9ee65
4 changed files with 52 additions and 4 deletions

View File

@@ -1262,6 +1262,27 @@ def Test_use_import_in_mapping()
nunmap <F3>
enddef
def Test_vim9script_mix()
var lines =<< trim END
if has(g:feature)
" legacy script
let g:legacy = 1
finish
endif
vim9script
g:legacy = 0
END
g:feature = 'eval'
g:legacy = -1
CheckScriptSuccess(lines)
assert_equal(1, g:legacy)
g:feature = 'noteval'
g:legacy = -1
CheckScriptSuccess(lines)
assert_equal(0, g:legacy)
enddef
def Test_vim9script_fails()
CheckScriptFailure(['scriptversion 2', 'vim9script'], 'E1039:')
CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:')