Patch 8.2.3168
Problem: Vim9: type error for constant of type any.
Solution: Do add a runtime type check if a constant has type any.
(closes #8570)
Files: src/vim9compile.c, src/testdir/test_vim9_assign.vim
*** ../vim-8.2.3167/src/vim9compile.c 2021-07-15 15:40:54.738804508 +0200
--- src/vim9compile.c 2021-07-15 19:21:01.681585500 +0200
***************
*** 1051,1057 ****
// If the actual type can be the expected type add a runtime check.
// If it's a constant a runtime check makes no sense.
! if (!actual_is_const && use_typecheck(actual, expected))
{
generate_TYPECHECK(cctx, expected, offset, arg_idx);
return OK;
--- 1051,1058 ----
// If the actual type can be the expected type add a runtime check.
// If it's a constant a runtime check makes no sense.
! if ((!actual_is_const || actual == &t_any)
! && use_typecheck(actual, expected))
{
generate_TYPECHECK(cctx, expected, offset, arg_idx);
return OK;
*** ../vim-8.2.3167/src/testdir/test_vim9_assign.vim 2021-07-04 23:29:26.821602887 +0200
--- src/testdir/test_vim9_assign.vim 2021-07-15 19:20:23.833640322 +0200
***************
*** 1667,1672 ****
--- 1667,1682 ----
s:d = {}
END
CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ var d = {a: 1, b: [2]}
+ def Func(b: bool)
+ var l: list<number> = b ? d.b : [3]
+ enddef
+ defcompile
+ END
+ CheckScriptSuccess(lines)
enddef
let g:dict_number = #{one: 1, two: 2}
*** ../vim-8.2.3167/src/version.c 2021-07-15 18:14:52.930849299 +0200
--- src/version.c 2021-07-15 19:13:05.214261831 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3168,
/**/
--
hundred-and-one symptoms of being an internet addict:
154. You fondle your mouse.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///