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 -- b...@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    ///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202107151723.16FHNjYA1943434%40masaka.moolenaar.net.

Raspunde prin e-mail lui