Mercurial > vim
diff src/vim9script.c @ 24279:e3dbf2e58c6a v8.2.2680
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Commit: https://github.com/vim/vim/commit/e535db86e76db5e8fcd2fa8ad54050e171e8adc3
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 31 21:07:24 2021 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 31 Mar 2021 21:15:03 +0200 |
parents | 12378fbc99bc |
children | bcfff560e089 |
line wrap: on
line diff
--- a/src/vim9script.c +++ b/src/vim9script.c @@ -17,17 +17,33 @@ # 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". */ void