0
0
mirror of https://github.com/vim/vim.git synced 2025-10-28 09:27:14 -04:00

patch 8.2.3142: Vim9: type check for has_key() argument is too strict

Problem:    Vim9: type check for has_key() argument is too strict.
Solution:   Also allow for a number key argument. (closes #8542)
This commit is contained in:
Bram Moolenaar
2021-07-11 14:55:49 +02:00
parent de69a7353e
commit 1aeddeb8bd
3 changed files with 10 additions and 1 deletions

View File

@@ -1131,6 +1131,12 @@ def Test_has()
enddef
def Test_has_key()
var d = {123: 'xx'}
assert_true(has_key(d, '123'))
assert_true(has_key(d, 123))
assert_false(has_key(d, 'x'))
assert_false(has_key(d, 99))
CheckDefAndScriptFailure2(['has_key([1, 2], "k")'], 'E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E715: Dictionary required')
CheckDefAndScriptFailure2(['has_key({"a": 10}, ["a"])'], 'E1013: Argument 2: type mismatch, expected string but got list<string>', 'E730: Using a List as a String')
enddef