diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-03-17 20:56:38 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-03-17 20:56:38 +0100 |
commit | 3f32788000258aabe078b426e3d71962bee9d2d1 (patch) | |
tree | b6ffc80bccf5d7200546b571390c5b9454973860 | |
parent | 8863bda25df821fc79bebf9dc73c79776ae5f675 (diff) | |
download | vim-git-8.2.2618.tar.gz |
patch 8.2.2618: Vim9: cannot use a normal list name to store function refsv8.2.2618
Problem: Vim9: cannot use a normal list name to store function refs.
Solution: Allow a lower case name if it is indexed.
-rw-r--r-- | src/testdir/test_vim9_assign.vim | 7 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 7 |
3 files changed, 14 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim index 23c0a89c8..f71226e1b 100644 --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -72,6 +72,13 @@ def Test_assignment() CheckDefFailure(['var lambda = () => "lambda"'], 'E704:') CheckScriptFailure(['var x = "x"'], 'E1124:') + # lower case name is OK for a list + var lambdaLines =<< trim END + var lambdaList: list<func> = [Test_syntax] + lambdaList[0] = () => "lambda" + END + CheckDefAndScriptSuccess(lambdaLines) + var nr: number = 1234 CheckDefFailure(['var nr: number = "asdf"'], 'E1012:') diff --git a/src/version.c b/src/version.c index 3bb4eceb7..6ac96acbd 100644 --- 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 */ /**/ + 2618, +/**/ 2617, /**/ 2616, diff --git a/src/vim9compile.c b/src/vim9compile.c index 93ded0857..458b4a1a3 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -5832,11 +5832,13 @@ compile_lhs( return FAIL; } - // new local variable + // Check the name is valid for a funcref. if ((lhs->lhs_type->tt_type == VAR_FUNC || lhs->lhs_type->tt_type == VAR_PARTIAL) - && var_wrong_func_name(lhs->lhs_name, TRUE)) + && var_wrong_func_name(lhs->lhs_name, TRUE)) return FAIL; + + // New local variable. lhs->lhs_lvar = reserve_local(cctx, var_start, lhs->lhs_varlen, cmdidx == CMD_final || cmdidx == CMD_const, lhs->lhs_type); if (lhs->lhs_lvar == NULL) @@ -6275,6 +6277,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx) { if ((rhs_type->tt_type == VAR_FUNC || rhs_type->tt_type == VAR_PARTIAL) + && !lhs.lhs_has_index && var_wrong_func_name(lhs.lhs_name, TRUE)) goto theend; |