summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-12-13 18:44:43 +0100
committerBram Moolenaar <Bram@vim.org>2020-12-13 18:44:43 +0100
commitacbae18df528b6aee72ecfd66e344dc8be7b3775 (patch)
treed2a2ef75e33a735a20c1016276fe08176af44ed4
parentb5b9480ee936ef4cd0e350c468ef8c5f42fa398b (diff)
downloadvim-git-acbae18df528b6aee72ecfd66e344dc8be7b3775.tar.gz
patch 8.2.2139: Vim9: unreachable code in assignmentv8.2.2139
Problem: Vim9: unreachable code in assignment. Solution: Don't check "new_local" when "has_index" is set. Add test for wrong type of list index.
-rw-r--r--src/testdir/test_vim9_assign.vim12
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c4
3 files changed, 14 insertions, 4 deletions
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index 1075e1712..60c8fe958 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -326,6 +326,18 @@ def Test_assign_index()
END
CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got dict<unknown>', 3)
+ lines =<< trim END
+ var lines: list<string>
+ lines['a'] = 'asdf'
+ END
+ CheckDefFailure(lines, 'E39:', 2)
+
+ lines =<< trim END
+ var lines: string
+ lines[9] = 'asdf'
+ END
+ CheckDefFailure(lines, 'E1141:', 2)
+
# list of dict
var ld: list<dict<number>>
ld[0] = {}
diff --git a/src/version.c b/src/version.c
index 2d39c1be5..f6c51e1f0 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 */
/**/
+ 2139,
+/**/
2138,
/**/
2137,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 6cbf7849e..3fae25e11 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -5856,8 +5856,6 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
int r;
// Compile the "idx" in "var[idx]" or "key" in "var.key".
- if (new_local)
- --cctx->ctx_locals.ga_len;
p = var_start + varlen;
if (*p == '[')
{
@@ -5877,8 +5875,6 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
r = generate_PUSHS(cctx, key);
}
- if (new_local)
- ++cctx->ctx_locals.ga_len;
if (r == FAIL)
goto theend;