diff src/vim9execute.c @ 24293:bbf4b3185554 v8.2.2687

patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function Commit: https://github.com/vim/vim/commit/d877a5700fe9d5b92562514924549316382384aa Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 1 19:42:48 2021 +0200 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 https://github.com/vim/vim/issues/8030)
author Bram Moolenaar <Bram@vim.org>
date Thu, 01 Apr 2021 19:45:02 +0200
parents cabed216cc2f
children 17b49af76766
line wrap: on
line diff
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -963,9 +963,12 @@ check_for_number(typval_T *tv)
 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();
 }