To: vim_dev@googlegroups.com Subject: Patch 8.2.2146 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2146 Problem: Vim9: automatic conversion of number to string for dict key. Solution: Do not convert number to string. (closes #7474) Files: src/dict.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.2145/src/dict.c 2020-12-06 16:03:51.601729887 +0100 --- src/dict.c 2020-12-15 21:36:57.134406193 +0100 *************** *** 951,956 **** --- 951,961 ---- } if (evaluate) { + if (vim9script && check_for_string(&tvkey) == FAIL) + { + clear_tv(&tvkey); + goto failret; + } key = tv_get_string_buf_chk(&tvkey, buf); if (key == NULL) { *** ../vim-8.2.2145/src/testdir/test_vim9_expr.vim 2020-12-15 21:28:53.660000912 +0100 --- src/testdir/test_vim9_expr.vim 2020-12-15 21:41:14.789557392 +0100 *************** *** 1989,1994 **** --- 1989,2002 ---- CheckDefFailure(['var x = ({'], 'E723:', 2) CheckDefExecFailure(['{}[getftype("file")]'], 'E716: Key not present in Dictionary: ""', 1) + + # no automatic conversion from number to string + lines =<< trim END + var n = 123 + var d = {[n]: 1} + END + CheckDefFailure(lines, 'E1012:', 2) + CheckScriptFailure(['vim9script'] + lines, 'E928:', 3) enddef def Test_expr7_dict_vim9script() *** ../vim-8.2.2145/src/version.c 2020-12-15 21:28:53.660000912 +0100 --- src/version.c 2020-12-15 21:37:57.782206023 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2146, /**/ -- Computers make very fast, very accurate, mistakes. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///