# HG changeset patch # User Bram Moolenaar # Date 1617220803 -7200 # Node ID 243985ba92b572bc13b1f4bd416b5e940df5e1ab # Parent 8ab83d4f5d2efb23f447d4cff41c1f5037d62faa patch 8.2.2681: Vim9: test fails for redeclaring script variable Commit: https://github.com/vim/vim/commit/12be734faffe1da04dfa9098e73abaa864204bc5 Author: Bram Moolenaar Date: Wed Mar 31 21:47:33 2021 +0200 patch 8.2.2681: Vim9: test fails for redeclaring script variable Problem: Vim9: test fails for redeclaring script variable. Solution: It's OK to assign to an existing script variable in legacy. diff --git a/src/evalvars.c b/src/evalvars.c --- a/src/evalvars.c +++ b/src/evalvars.c @@ -3219,16 +3219,17 @@ set_var_const( goto failed; } + if (is_script_local && vim9script + && (flags & (ASSIGN_NO_DECL | ASSIGN_DECL)) == 0) + { + semsg(_(e_redefining_script_item_str), name); + goto failed; + } + if (var_in_vim9script) { where_T where; - if ((flags & (ASSIGN_NO_DECL | ASSIGN_DECL)) == 0) - { - semsg(_(e_redefining_script_item_str), name); - goto failed; - } - // check the type and adjust to bool if needed where.wt_index = var_idx; where.wt_variable = TRUE; diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2681, +/**/ 2680, /**/ 2679,