diff src/testdir/test_vim9_assign.vim @ 22631:59cd5f8b2ab2 v8.2.1864

patch 8.2.1864: Vim9: no error for wrong list type Commit: https://github.com/vim/vim/commit/334a8b4bde55e1095533f70616ac1e6ec337c62c Author: Bram Moolenaar <Bram@vim.org> Date: Mon Oct 19 16:07:42 2020 +0200 patch 8.2.1864: Vim9: no error for wrong list type Problem: Vim9: no error for wrong list type. Solution: Add flag to indicate a constant. (closes https://github.com/vim/vim/issues/7160)
author Bram Moolenaar <Bram@vim.org>
date Mon, 19 Oct 2020 16:15:04 +0200
parents 576a69fc0066
children 3e0f909ca1f2
line wrap: on
line diff
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -702,6 +702,9 @@ def Test_assign_list()
     nrl[i] = i
   endfor
   assert_equal([0, 1, 2, 3, 4], nrl)
+
+  CheckDefFailure(["var l: list<number> = ['', true]"], 'E1012: Type mismatch; expected list<number> but got list<any>', 1)
+  CheckDefFailure(["var l: list<list<number>> = [['', true]]"], 'E1012: Type mismatch; expected list<list<number>> but got list<list<any>>', 1)
 enddef
 
 def Test_assign_dict()
@@ -718,6 +721,9 @@ def Test_assign_dict()
     nrd[i] = i
   endfor
   assert_equal({'0': 0, '1': 1, '2': 2}, nrd)
+
+  CheckDefFailure(["var d: dict<number> = #{a: '', b: true}"], 'E1012: Type mismatch; expected dict<number> but got dict<any>', 1)
+  CheckDefFailure(["var d: dict<dict<number>> = #{x: #{a: '', b: true}}"], 'E1012: Type mismatch; expected dict<dict<number>> but got dict<dict<any>>', 1)
 enddef
 
 def Test_assign_dict_unknown_type()