summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-03-10 18:43:09 +0100
committerBram Moolenaar <Bram@vim.org>2021-03-10 18:43:09 +0100
commitd345fb921678613ffc66a8afc82bc0e815c72312 (patch)
tree2957b1d12eb756b0b14d70f79be9851fb7d38291
parent7ad67d1150a1e48371d64e2919591c38b80e7cfc (diff)
downloadvim-git-d345fb921678613ffc66a8afc82bc0e815c72312.tar.gz
patch 8.2.2584: Vim9: type error for assigning "any" to a listv8.2.2584
Problem: Vim9: type error for assigning the result of list concatenation to a list. Solution: Do not consider concatenation result in a constant. (closes #7942)
-rw-r--r--src/testdir/test_vim9_expr.vim3
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c3
3 files changed, 7 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index a55de7e83..a78cf1983 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -1370,6 +1370,9 @@ def Test_expr5_list_add()
dany[i] = i
endfor
assert_equal({a: 'a', 12: 12}, dany)
+
+ # result of glob() is "any", runtime type check
+ var sl: list<string> = glob('*.txt', false, true) + ['']
enddef
" test multiply, divide, modulo
diff --git a/src/version.c b/src/version.c
index 2dbf24a64..65a3f5019 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 */
/**/
+ 2584,
+/**/
2583,
/**/
2582,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index c78106023..7c1dca533 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -4450,7 +4450,7 @@ compile_expr6(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
}
/*
- * + number addition
+ * + number addition or list/blobl concatenation
* - number subtraction
* .. string concatenation
*/
@@ -4532,6 +4532,7 @@ compile_expr5(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
else
{
generate_ppconst(cctx, ppconst);
+ ppconst->pp_is_const = FALSE;
if (*op == '.')
{
if (may_generate_2STRING(-2, cctx) == FAIL