]> granicus.if.org Git - vim/commitdiff
patch 8.2.2584: Vim9: type error for assigning "any" to a list v8.2.2584
authorBram Moolenaar <Bram@vim.org>
Wed, 10 Mar 2021 17:43:09 +0000 (18:43 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 10 Mar 2021 17:43:09 +0000 (18:43 +0100)
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)

src/testdir/test_vim9_expr.vim
src/version.c
src/vim9compile.c

index a55de7e83acd224ba8176c181571c870177c5124..a78cf1983f806246115aa2a0086fd335fd7cc4fd 100644 (file)
@@ -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
index 2dbf24a64f8bdf70672f7310d9f481a212da4c55..65a3f50192e817355e9aea0b81e0e2de04a3e3cb 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2584,
 /**/
     2583,
 /**/
index c7810602373c098a4177631a73b91c1d26d4f21a..7c1dca533af422f0d6cacf59b306ae8ae888564f 100644 (file)
@@ -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