• R/O
  • SSH

vim: 提交

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

修訂a5b16c9eee9db03f6ce938338d4cf267d9bbca53 (tree)
時間2020-09-19 21:15:04
作者Bram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.1710: Vim9: list of list type can be wrong

Commit: https://github.com/vim/vim/commit/77b20977dc31ecf753dddad7a7c7b8f7b6e0c244
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 19 14:12:34 2020 +0200

patch 8.2.1710: Vim9: list of list type can be wrong
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)

Change Summary

差異

diff -r 44ebaac84a54 -r a5b16c9eee9d src/testdir/test_vim9_expr.vim
--- a/src/testdir/test_vim9_expr.vim Fri Sep 18 23:15:04 2020 +0200
+++ b/src/testdir/test_vim9_expr.vim Sat Sep 19 14:15:04 2020 +0200
@@ -1513,6 +1513,10 @@
15131513 2] [3,
15141514 4]
15151515
1516+ let llstring: list<list<string>> = [['text'], []]
1517+ llstring = [[], ['text']]
1518+ llstring = [[], []]
1519+
15161520 CheckDefFailure(["let x = 1234[3]"], 'E1107:', 1)
15171521 CheckDefExecFailure(["let x = g:anint[3]"], 'E1062:', 1)
15181522
@@ -1718,6 +1722,14 @@
17181722 mixed = #{a: 234}
17191723 mixed = #{}
17201724
1725+ let dictlist: dict<list<string>> = #{absent: [], present: ['hi']}
1726+ dictlist = #{absent: ['hi'], present: []}
1727+ dictlist = #{absent: [], present: []}
1728+
1729+ let dictdict: dict<dict<string>> = #{one: #{a: 'text'}, two: #{}}
1730+ dictdict = #{one: #{}, two: #{a: 'text'}}
1731+ dictdict = #{one: #{}, two: #{}}
1732+
17211733 CheckDefFailure(["let x = #{a:8}"], 'E1069:', 1)
17221734 CheckDefFailure(["let x = #{a : 8}"], 'E1068:', 1)
17231735 CheckDefFailure(["let x = #{a :8}"], 'E1068:', 1)
diff -r 44ebaac84a54 -r a5b16c9eee9d src/version.c
--- a/src/version.c Fri Sep 18 23:15:04 2020 +0200
+++ b/src/version.c Sat Sep 19 14:15:04 2020 +0200
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 1710,
755+/**/
754756 1709,
755757 /**/
756758 1708,
diff -r 44ebaac84a54 -r a5b16c9eee9d src/vim9type.c
--- a/src/vim9type.c Fri Sep 18 23:15:04 2020 +0200
+++ b/src/vim9type.c Sat Sep 19 14:15:04 2020 +0200
@@ -869,6 +869,19 @@
869869 return;
870870 }
871871
872+ // If either is VAR_UNKNOWN use the other type. An empty list/dict has no
873+ // specific type.
874+ if (type1->tt_type == VAR_UNKNOWN)
875+ {
876+ *dest = type2;
877+ return;
878+ }
879+ if (type2->tt_type == VAR_UNKNOWN)
880+ {
881+ *dest = type1;
882+ return;
883+ }
884+
872885 if (type1->tt_type == type2->tt_type)
873886 {
874887 if (type1->tt_type == VAR_LIST || type2->tt_type == VAR_DICT)
@@ -932,7 +945,7 @@
932945
933946 // Use "any" for an empty list or dict.
934947 if (count == 0)
935- return &t_void;
948+ return &t_unknown;
936949
937950 // Use the first value type for the list member type, then find the common
938951 // type from following items.
Show on old repository browser