comparison src/testdir/test_vim9_builtin.vim @ 27392:ec2ba9acec1b v8.2.4224

patch 8.2.4224: Vim9: no error when using a number for map() second argument Commit: https://github.com/vim/vim/commit/1080c48ec8d672d7e9fbefb5a1255c9df09a2884 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 26 18:26:21 2022 +0000 patch 8.2.4224: Vim9: no error when using a number for map() second argument Problem: Vim9: no error when using a number for map() second argument Solution: Disallow number to string conversion. (closes https://github.com/vim/vim/issues/9630)
author Bram Moolenaar <Bram@vim.org>
date Wed, 26 Jan 2022 19:30:03 +0100
parents 95f202f77cbb
children 898f520e798b
comparison
equal deleted inserted replaced
27391:5854ea4dc132 27392:ec2ba9acec1b
1273 return filter(items, (_, val) => get({[val]: 1}, 'x')) 1273 return filter(items, (_, val) => get({[val]: 1}, 'x'))
1274 enddef 1274 enddef
1275 1275
1276 def Test_filter() 1276 def Test_filter()
1277 CheckDefAndScriptFailure(['filter(1.1, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got float', 'E1251: List, Dictionary, Blob or String required for argument 1']) 1277 CheckDefAndScriptFailure(['filter(1.1, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got float', 'E1251: List, Dictionary, Blob or String required for argument 1'])
1278 CheckDefAndScriptFailure(['filter([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String'])
1278 1279
1279 var lines =<< trim END 1280 var lines =<< trim END
1280 def F(i: number, v: any): string 1281 def F(i: number, v: any): string
1281 return 'bad' 1282 return 'bad'
1282 enddef 1283 enddef
2151 def Test_map() 2152 def Test_map()
2152 if has('channel') 2153 if has('channel')
2153 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']) 2154 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'])
2154 endif 2155 endif
2155 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']) 2156 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'])
2157 CheckDefAndScriptFailure(['map([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String'])
2156 2158
2157 # type of dict remains dict<any> even when type of values changes 2159 # type of dict remains dict<any> even when type of values changes
2158 # same for list 2160 # same for list
2159 var lines =<< trim END 2161 var lines =<< trim END
2160 var d: dict<any> = {a: 0} 2162 var d: dict<any> = {a: 0}