Patch 8.2.1710
Problem: Vim9: list of list type can be wrong.
Solution: Use VAR_UNKNOWN for empty list. Recognize VAR_UNKNOWN when
looking for a common type. (closes #6979)
Files: src/vim9type.c, src/testdir/test_vim9_expr.vim
*** ../vim-8.2.1709/src/vim9type.c 2020-09-16 15:21:56.354720354 +0200
--- src/vim9type.c 2020-09-19 14:03:22.244666176 +0200
***************
*** 869,874 ****
--- 869,887 ----
return;
}
+ // If either is VAR_UNKNOWN use the other type. An empty list/dict has no
+ // specific type.
+ if (type1->tt_type == VAR_UNKNOWN)
+ {
+ *dest = type2;
+ return;
+ }
+ if (type2->tt_type == VAR_UNKNOWN)
+ {
+ *dest = type1;
+ return;
+ }
+
if (type1->tt_type == type2->tt_type)
{
if (type1->tt_type == VAR_LIST || type2->tt_type == VAR_DICT)
***************
*** 932,938 ****
// Use "any" for an empty list or dict.
if (count == 0)
! return &t_void;
// Use the first value type for the list member type, then find the common
// type from following items.
--- 945,951 ----
// Use "any" for an empty list or dict.
if (count == 0)
! return &t_unknown;
// Use the first value type for the list member type, then find the common
// type from following items.
*** ../vim-8.2.1709/src/testdir/test_vim9_expr.vim 2020-09-16 17:55:36.537602345 +0200
--- src/testdir/test_vim9_expr.vim 2020-09-19 14:08:30.359709400 +0200
***************
*** 1513,1518 ****
--- 1513,1522 ----
2] [3,
4]
+ let llstring: list<list<string>> = [['text'], []]
+ llstring = [[], ['text']]
+ llstring = [[], []]
+
CheckDefFailure(["let x = 1234[3]"], 'E1107:', 1)
CheckDefExecFailure(["let x = g:anint[3]"], 'E1062:', 1)
***************
*** 1718,1723 ****
--- 1722,1735 ----
mixed = #{a: 234}
mixed = #{}
+ let dictlist: dict<list<string>> = #{absent: [], present: ['hi']}
+ dictlist = #{absent: ['hi'], present: []}
+ dictlist = #{absent: [], present: []}
+
+ let dictdict: dict<dict<string>> = #{one: #{a: 'text'}, two: #{}}
+ dictdict = #{one: #{}, two: #{a: 'text'}}
+ dictdict = #{one: #{}, two: #{}}
+
CheckDefFailure(["let x = #{a:8}"], 'E1069:', 1)
CheckDefFailure(["let x = #{a : 8}"], 'E1068:', 1)
CheckDefFailure(["let x = #{a :8}"], 'E1068:', 1)
*** ../vim-8.2.1709/src/version.c 2020-09-18 23:11:06.682527750 +0200
--- src/version.c 2020-09-19 14:02:46.156776387 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1710,
/**/
--
./configure
Checking whether build environment is sane ...
build environment is grinning and holding a spatula. Guess not.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///