Mercurial > vim
diff src/evalvars.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 | db5eaad456cc |
children | 243985ba92b5 |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -3168,6 +3168,7 @@ set_var_const( hashtab_T *ht; int is_script_local; int vim9script = in_vim9script(); + int var_in_vim9script; ht = find_var_ht(name, &varname); if (ht == NULL || *varname == NUL) @@ -3186,6 +3187,7 @@ set_var_const( vim9_declare_error(name); goto failed; } + var_in_vim9script = is_script_local && current_script_is_vim9(); di = find_var_in_ht(ht, 0, varname, TRUE); @@ -3217,7 +3219,7 @@ set_var_const( goto failed; } - if (is_script_local && vim9script) + if (var_in_vim9script) { where_T where; @@ -3244,7 +3246,7 @@ set_var_const( // A Vim9 script-local variable is also present in sn_all_vars and // sn_var_vals. It may set "type" from "tv". - if (is_script_local && vim9script) + if (var_in_vim9script) update_vim9_script_var(FALSE, di, flags, tv, &type); } @@ -3308,7 +3310,7 @@ set_var_const( } // add a new variable - if (vim9script && is_script_local && (flags & ASSIGN_NO_DECL)) + if (var_in_vim9script && (flags & ASSIGN_NO_DECL)) { semsg(_(e_unknown_variable_str), name); goto failed; @@ -3342,7 +3344,7 @@ set_var_const( // A Vim9 script-local variable is also added to sn_all_vars and // sn_var_vals. It may set "type" from "tv". - if (is_script_local && vim9script) + if (var_in_vim9script) update_vim9_script_var(TRUE, di, flags, tv, &type); }