0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.2680: Vim9: problem defining a script variable from legacy function

Problem:    Vim9: problem defining a script variable from legacy function.
Solution:   Check if the script is Vim9, not the current syntax.
            (closes #8032)
This commit is contained in:
Bram Moolenaar
2021-03-31 21:07:24 +02:00
parent dad4473f02
commit e535db86e7
5 changed files with 57 additions and 7 deletions

View File

@@ -17,16 +17,32 @@
# include "vim9.h"
#endif
/*
* Return TRUE when currently using Vim9 script syntax.
* Does not go up the stack, a ":function" inside vim9script uses legacy
* syntax.
*/
int
in_vim9script(void)
{
// Do not go up the stack, a ":function" inside vim9script uses legacy
// syntax. "sc_version" is also set when compiling a ":def" function in
// legacy script.
// "sc_version" is also set when compiling a ":def" function in legacy
// script.
return current_sctx.sc_version == SCRIPT_VERSION_VIM9
|| (cmdmod.cmod_flags & CMOD_VIM9CMD);
}
/*
* Return TRUE if the current script is Vim9 script.
* This also returns TRUE in a legacy function in a Vim9 script.
*/
int
current_script_is_vim9(void)
{
return SCRIPT_ID_VALID(current_sctx.sc_sid)
&& SCRIPT_ITEM(current_sctx.sc_sid)->sn_version
== SCRIPT_VERSION_VIM9;
}
/*
* ":vim9script".
*/