diff src/testdir/test_vim9_builtin.vim @ 25212:79eb112b492d v8.2.3142

patch 8.2.3142: Vim9: type check for has_key() argument is too strict Commit: https://github.com/vim/vim/commit/1aeddeb8bd29a69fa118734c7f27d7df1b37801f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 11 14:55:49 2021 +0200 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 https://github.com/vim/vim/issues/8542)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Jul 2021 15:00:03 +0200
parents eafc0e07b188
children 9ead67e3c696
line wrap: on
line diff
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -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