Mercurial > vim
diff src/testdir/test_vim9_script.vim @ 22266:23f5750146d9 v8.2.1682
patch 8.2.1682: Vim9: const works in an unexpected way
Commit: https://github.com/vim/vim/commit/dbeecb2b6bc5bf90b7345807e0a313fe890a7c7b
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 14 18:15:09 2020 +0200
patch 8.2.1682: Vim9: const works in an unexpected way
Problem: Vim9: const works in an unexpected way.
Solution: ":const" only disallows changing the variable, not the value.
Make "list[0] = 9" work at the script level.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 14 Sep 2020 18:30:04 +0200 |
parents | e0a4d029cb87 |
children | eb1f5f618c75 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -821,8 +821,15 @@ enddef def Test_const() CheckDefFailure(['const var = 234', 'var = 99'], 'E1018:') CheckDefFailure(['const one = 234', 'let one = 99'], 'E1017:') + CheckDefFailure(['const list = [1, 2]', 'let list = [3, 4]'], 'E1017:') CheckDefFailure(['const two'], 'E1021:') CheckDefFailure(['const &option'], 'E996:') + + let lines =<< trim END + const list = [1, 2, 3] + list[0] = 4 + END + CheckDefAndScriptSuccess(lines) enddef def Test_range_no_colon()