patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Problem: Vim9: cannot use "const" for global variable in :def function.
Solution: Do allow using :const for a global variable. (closes #8030)
diff --git a/src/vim9execute.c b/src/vim9execute.c
index f15b93d..9b7f87b 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -963,9 +963,12 @@
store_var(char_u *name, typval_T *tv)
{
funccal_entry_T entry;
+ int flags = ASSIGN_DECL;
+ if (tv->v_lock)
+ flags |= ASSIGN_CONST;
save_funccal(&entry);
- set_var_const(name, NULL, tv, FALSE, ASSIGN_DECL, 0);
+ set_var_const(name, NULL, tv, FALSE, flags, 0);
restore_funccal();
}