Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
24278:4ab4ef0c48b1 | 24279:e3dbf2e58c6a |
---|---|
15 | 15 |
16 #if defined(FEAT_EVAL) | 16 #if defined(FEAT_EVAL) |
17 # include "vim9.h" | 17 # include "vim9.h" |
18 #endif | 18 #endif |
19 | 19 |
20 /* | |
21 * Return TRUE when currently using Vim9 script syntax. | |
22 * Does not go up the stack, a ":function" inside vim9script uses legacy | |
23 * syntax. | |
24 */ | |
20 int | 25 int |
21 in_vim9script(void) | 26 in_vim9script(void) |
22 { | 27 { |
23 // Do not go up the stack, a ":function" inside vim9script uses legacy | 28 // "sc_version" is also set when compiling a ":def" function in legacy |
24 // syntax. "sc_version" is also set when compiling a ":def" function in | 29 // script. |
25 // legacy script. | |
26 return current_sctx.sc_version == SCRIPT_VERSION_VIM9 | 30 return current_sctx.sc_version == SCRIPT_VERSION_VIM9 |
27 || (cmdmod.cmod_flags & CMOD_VIM9CMD); | 31 || (cmdmod.cmod_flags & CMOD_VIM9CMD); |
32 } | |
33 | |
34 /* | |
35 * Return TRUE if the current script is Vim9 script. | |
36 * This also returns TRUE in a legacy function in a Vim9 script. | |
37 */ | |
38 int | |
39 current_script_is_vim9(void) | |
40 { | |
41 return SCRIPT_ID_VALID(current_sctx.sc_sid) | |
42 && SCRIPT_ITEM(current_sctx.sc_sid)->sn_version | |
43 == SCRIPT_VERSION_VIM9; | |
28 } | 44 } |
29 | 45 |
30 /* | 46 /* |
31 * ":vim9script". | 47 * ":vim9script". |
32 */ | 48 */ |