Mercurial > vim
diff src/vim9compile.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 | bcfff560e089 |
children | 7f634eae21fe |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -5752,7 +5752,8 @@ compile_lhs( &lhs->lhs_opt_flags, &lhs->lhs_vimvaridx, &lhs->lhs_type, cctx) == FAIL) return FAIL; - if (lhs->lhs_dest != dest_local) + if (lhs->lhs_dest != dest_local + && cmdidx != CMD_const && cmdidx != CMD_final) { // Specific kind of variable recognized. declare_error = is_decl; @@ -6519,6 +6520,7 @@ compile_assignment(char_u *arg, exarg_T else { if (is_decl && cmdidx == CMD_const && (lhs.lhs_dest == dest_script + || lhs.lhs_dest == dest_global || lhs.lhs_dest == dest_local)) // ":const var": lock the value, but not referenced variables generate_LOCKCONST(cctx);