0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.2584: Vim9: type error for assigning "any" to a list

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)
This commit is contained in:
Bram Moolenaar
2021-03-10 18:43:09 +01:00
parent 7ad67d1150
commit d345fb9216
3 changed files with 7 additions and 1 deletions

View File

@@ -1370,6 +1370,9 @@ def Test_expr5_list_add()
dany[i] = i dany[i] = i
endfor endfor
assert_equal({a: 'a', 12: 12}, dany) assert_equal({a: 'a', 12: 12}, dany)
# result of glob() is "any", runtime type check
var sl: list<string> = glob('*.txt', false, true) + ['']
enddef enddef
" test multiply, divide, modulo " test multiply, divide, modulo

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2584,
/**/ /**/
2583, 2583,
/**/ /**/

View 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 * - number subtraction
* .. string concatenation * .. string concatenation
*/ */
@@ -4532,6 +4532,7 @@ compile_expr5(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
else else
{ {
generate_ppconst(cctx, ppconst); generate_ppconst(cctx, ppconst);
ppconst->pp_is_const = FALSE;
if (*op == '.') if (*op == '.')
{ {
if (may_generate_2STRING(-2, cctx) == FAIL if (may_generate_2STRING(-2, cctx) == FAIL