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 -- [email protected] -- 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 ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202012152042.0BFKgU82448381%40masaka.moolenaar.net.