diff src/testdir/test_vim9_builtin.vim @ 26925:4e77f9961650 v8.2.3991

patch 8.2.3991: Vim9: error when extending dict<any> Commit: https://github.com/vim/vim/commit/114dbda7858df956161c0adba5d4d8279645ff67 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 3 12:28:03 2022 +0000 patch 8.2.3991: Vim9: error when extending dict<any> Problem: Vim9: error when extending dict<any> with another type that it was initialized with. Solution: Also set the type for dict<any> if the initializer has a more specific type. (closes #9461)
author Bram Moolenaar <Bram@vim.org>
date Mon, 03 Jan 2022 13:30:04 +0100
parents 6f43253463cc
children 6cdf92e77a91
line wrap: on
line diff
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -2143,6 +2143,11 @@ def Test_map()
     CheckDefAndScriptFailure(['map(test_null_channel(), "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got channel', 'E1251: List, Dictionary, Blob or String required for argument 1'])
   endif
   CheckDefAndScriptFailure(['map(1, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1251: List, Dictionary, Blob or String required for argument 1'])
+
+  # type of dict remains dict<any> even when type of values changes
+  var d: dict<any> = {a: 0}
+  d->map((k, v) => true)
+  d->map((k, v) => 'x')
 enddef
 
 def Test_map_failure()