Patch 8.2.4279
Problem:    Vim9: cannot change item type with map() after range().
Solution:   Split the return type in current type and declared type.
            (closes #9665)
Files:      src/evalfunc.c, src/proto/evalfunc.pro, src/vim9instr.c,
            src/vim9type.c, src/proto/vim9type.pro,
            src/testdir/test_vim9_builtin.vim


*** ../vim-8.2.4278/src/evalfunc.c      2022-01-31 17:39:45.394105533 +0000
--- src/evalfunc.c      2022-02-01 12:01:21.488896698 +0000
***************
*** 992,1118 ****
   * Note that "argtypes" is NULL if "argcount" is zero.
   */
      static type_T *
! ret_void(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_void;
  }
      static type_T *
! ret_any(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_any;
  }
      static type_T *
! ret_bool(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_bool;
  }
      static type_T *
! ret_number_bool(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_number_bool;
  }
      static type_T *
! ret_number(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_number;
  }
      static type_T *
! ret_float(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_float;
  }
      static type_T *
! ret_string(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_string;
  }
      static type_T *
! ret_list_any(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_list_any;
  }
      static type_T *
! ret_list_number(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_list_number;
  }
      static type_T *
! ret_list_string(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_list_string;
  }
      static type_T *
! ret_list_dict_any(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_list_dict_any;
  }
      static type_T *
! ret_list_items(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_list_list_any;
  }
  
      static type_T *
! ret_list_string_items(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_list_list_string;
  }
      static type_T *
! ret_dict_any(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_dict_any;
  }
      static type_T *
! ret_job_info(int argcount, type2_T *argtypes UNUSED)
  {
      if (argcount == 0)
        return &t_list_job;
      return &t_dict_any;
  }
      static type_T *
! ret_dict_number(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_dict_number;
  }
      static type_T *
! ret_dict_string(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_dict_string;
  }
      static type_T *
! ret_blob(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_blob;
  }
      static type_T *
! ret_func_any(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_func_any;
  }
      static type_T *
! ret_func_unknown(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_func_unknown;
  }
      static type_T *
! ret_channel(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_channel;
  }
      static type_T *
! ret_job(int argcount UNUSED, type2_T *argtypes UNUSED)
  {
      return &t_job;
  }
      static type_T *
! ret_first_arg(int argcount, type2_T *argtypes)
  {
      if (argcount > 0)
        return argtypes[0].type_curr;
      return &t_void;
  }
      static type_T *
! ret_repeat(int argcount, type2_T *argtypes)
  {
      if (argcount == 0)
        return &t_any;
--- 992,1200 ----
   * Note that "argtypes" is NULL if "argcount" is zero.
   */
      static type_T *
! ret_void(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_void;
  }
      static type_T *
! ret_any(int   argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_any;
  }
      static type_T *
! ret_bool(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_bool;
  }
      static type_T *
! ret_number_bool(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_number_bool;
  }
      static type_T *
! ret_number(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_number;
  }
      static type_T *
! ret_float(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_float;
  }
      static type_T *
! ret_string(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_string;
  }
      static type_T *
! ret_list_any(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_list_any;
  }
      static type_T *
! ret_list_number(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_list_number;
  }
      static type_T *
! ret_range(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type)
! {
!     // returning a list<number>, but it's not declared as such
!     *decl_type = &t_list_any;
!     return &t_list_number;
! }
!     static type_T *
! ret_list_string(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_list_string;
  }
      static type_T *
! ret_list_dict_any(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_list_dict_any;
  }
      static type_T *
! ret_list_items(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_list_list_any;
  }
  
      static type_T *
! ret_list_string_items(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_list_list_string;
  }
      static type_T *
! ret_dict_any(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_dict_any;
  }
      static type_T *
! ret_job_info(int argcount,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      if (argcount == 0)
        return &t_list_job;
      return &t_dict_any;
  }
      static type_T *
! ret_dict_number(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_dict_number;
  }
      static type_T *
! ret_dict_string(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_dict_string;
  }
      static type_T *
! ret_blob(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_blob;
  }
      static type_T *
! ret_func_any(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_func_any;
  }
      static type_T *
! ret_func_unknown(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_func_unknown;
  }
      static type_T *
! ret_channel(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_channel;
  }
      static type_T *
! ret_job(int argcount UNUSED,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return &t_job;
  }
      static type_T *
! ret_first_arg(int argcount,
!       type2_T *argtypes,
!       type_T  **decl_type)
  {
      if (argcount > 0)
+     {
+       *decl_type = argtypes[0].type_decl;
        return argtypes[0].type_curr;
+     }
      return &t_void;
  }
      static type_T *
! ret_extend(int argcount,
!       type2_T *argtypes,
!       type_T  **decl_type)
! {
!     if (argcount > 0)
!     {
!       *decl_type = argtypes[0].type_decl;
!       // if the second argument has a different current type then the current
!       // type is "any"
!       if (argcount > 1 && !equal_type(argtypes[0].type_curr,
!                                                    argtypes[1].type_curr, 0))
!       {
!           if (argtypes[0].type_curr->tt_type == VAR_LIST)
!               return &t_list_any;
!           if (argtypes[0].type_curr->tt_type == VAR_DICT)
!               return &t_dict_any;
!       }
!       return argtypes[0].type_curr;
!     }
!     return &t_void;
! }
!     static type_T *
! ret_repeat(int argcount,
!       type2_T *argtypes,
!       type_T  **decl_type UNUSED)
  {
      if (argcount == 0)
        return &t_any;
***************
*** 1122,1128 ****
  }
  // for map(): returns first argument but item type may differ
      static type_T *
! ret_first_cont(int argcount, type2_T *argtypes)
  {
      if (argcount > 0)
      {
--- 1204,1212 ----
  }
  // for map(): returns first argument but item type may differ
      static type_T *
! ret_first_cont(int argcount,
!       type2_T *argtypes,
!       type_T  **decl_type UNUSED)
  {
      if (argcount > 0)
      {
***************
*** 1137,1149 ****
  }
  // for getline()
      static type_T *
! ret_getline(int argcount, type2_T *argtypes UNUSED)
  {
      return argcount == 1 ? &t_string : &t_list_string;
  }
  // for finddir()
      static type_T *
! ret_finddir(int argcount, type2_T *argtypes UNUSED)
  {
      if (argcount < 3)
        return &t_string;
--- 1221,1237 ----
  }
  // for getline()
      static type_T *
! ret_getline(int argcount,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      return argcount == 1 ? &t_string : &t_list_string;
  }
  // for finddir()
      static type_T *
! ret_finddir(int argcount,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      if (argcount < 3)
        return &t_string;
***************
*** 1156,1162 ****
   * one.
   */
      static type_T *
! ret_list_or_dict_0(int argcount, type2_T *argtypes UNUSED)
  {
      if (argcount > 0)
        return &t_dict_any;
--- 1244,1252 ----
   * one.
   */
      static type_T *
! ret_list_or_dict_0(int argcount,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      if (argcount > 0)
        return &t_dict_any;
***************
*** 1168,1174 ****
   * are two.
   */
      static type_T *
! ret_list_or_dict_1(int argcount, type2_T *argtypes UNUSED)
  {
      if (argcount > 1)
        return &t_dict_any;
--- 1258,1266 ----
   * are two.
   */
      static type_T *
! ret_list_or_dict_1(int argcount,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      if (argcount > 1)
        return &t_dict_any;
***************
*** 1176,1182 ****
  }
  
      static type_T *
! ret_argv(int argcount, type2_T *argtypes UNUSED)
  {
      // argv() returns list of strings
      if (argcount == 0)
--- 1268,1276 ----
  }
  
      static type_T *
! ret_argv(int argcount,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      // argv() returns list of strings
      if (argcount == 0)
***************
*** 1187,1199 ****
  }
  
      static type_T *
! ret_remove(int argcount, type2_T *argtypes)
  {
      if (argcount > 0)
      {
        if (argtypes[0].type_curr->tt_type == VAR_LIST
                || argtypes[0].type_curr->tt_type == VAR_DICT)
            return argtypes[0].type_curr->tt_member;
        if (argtypes[0].type_curr->tt_type == VAR_BLOB)
            return &t_number;
      }
--- 1281,1300 ----
  }
  
      static type_T *
! ret_remove(int argcount,
!       type2_T *argtypes,
!       type_T  **decl_type UNUSED)
  {
      if (argcount > 0)
      {
        if (argtypes[0].type_curr->tt_type == VAR_LIST
                || argtypes[0].type_curr->tt_type == VAR_DICT)
+       {
+           if (argtypes[0].type_curr->tt_type
+                                            == argtypes[0].type_decl->tt_type)
+               *decl_type = argtypes[0].type_decl->tt_member;
            return argtypes[0].type_curr->tt_member;
+       }
        if (argtypes[0].type_curr->tt_type == VAR_BLOB)
            return &t_number;
      }
***************
*** 1201,1207 ****
  }
  
      static type_T *
! ret_getreg(int argcount, type2_T *argtypes UNUSED)
  {
      // Assume that if the third argument is passed it's non-zero
      if (argcount == 3)
--- 1302,1310 ----
  }
  
      static type_T *
! ret_getreg(int argcount,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      // Assume that if the third argument is passed it's non-zero
      if (argcount == 3)
***************
*** 1210,1216 ****
  }
  
      static type_T *
! ret_maparg(int argcount, type2_T *argtypes UNUSED)
  {
      // Assume that if the fourth argument is passed it's non-zero
      if (argcount == 4)
--- 1313,1321 ----
  }
  
      static type_T *
! ret_maparg(int argcount,
!       type2_T *argtypes UNUSED,
!       type_T  **decl_type UNUSED)
  {
      // Assume that if the fourth argument is passed it's non-zero
      if (argcount == 4)
***************
*** 1229,1235 ****
      char      f_max_argc;     // maximal number of arguments
      char      f_argtype;      // for method: FEARG_ values
      argcheck_T        *f_argcheck;    // list of functions to check argument 
types
!     type_T    *(*f_retfunc)(int argcount, type2_T *argtypes);
                                // return type function
      void      (*f_func)(typval_T *args, typval_T *rvar);
                                // implementation of function
--- 1334,1341 ----
      char      f_max_argc;     // maximal number of arguments
      char      f_argtype;      // for method: FEARG_ values
      argcheck_T        *f_argcheck;    // list of functions to check argument 
types
!     type_T    *(*f_retfunc)(int argcount, type2_T *argtypes,
!                                                          type_T **decl_type);
                                // return type function
      void      (*f_func)(typval_T *args, typval_T *rvar);
                                // implementation of function
***************
*** 1533,1539 ****
      {"expandcmd",     1, 1, FEARG_1,      arg1_string,
                        ret_string,         f_expandcmd},
      {"extend",                2, 3, FEARG_1,      arg23_extend,
!                       ret_first_arg,      f_extend},
      {"extendnew",     2, 3, FEARG_1,      arg23_extendnew,
                        ret_first_cont,     f_extendnew},
      {"feedkeys",      1, 2, FEARG_1,      arg2_string,
--- 1639,1645 ----
      {"expandcmd",     1, 1, FEARG_1,      arg1_string,
                        ret_string,         f_expandcmd},
      {"extend",                2, 3, FEARG_1,      arg23_extend,
!                       ret_extend,         f_extend},
      {"extendnew",     2, 3, FEARG_1,      arg23_extendnew,
                        ret_first_cont,     f_extendnew},
      {"feedkeys",      1, 2, FEARG_1,      arg2_string,
***************
*** 1991,1997 ****
      {"rand",          0, 1, FEARG_1,      arg1_list_number,
                        ret_number,         f_rand},
      {"range",         1, 3, FEARG_1,      arg3_number,
!                       ret_list_number,    f_range},
      {"readblob",      1, 1, FEARG_1,      arg1_string,
                        ret_blob,           f_readblob},
      {"readdir",               1, 3, FEARG_1,      arg3_string_any_dict,
--- 2097,2103 ----
      {"rand",          0, 1, FEARG_1,      arg1_list_number,
                        ret_number,         f_rand},
      {"range",         1, 3, FEARG_1,      arg3_number,
!                       ret_range,          f_range},
      {"readblob",      1, 1, FEARG_1,      arg1_string,
                        ret_blob,           f_readblob},
      {"readdir",               1, 3, FEARG_1,      arg3_string_any_dict,
***************
*** 2622,2635 ****
  
  /*
   * Call the "f_retfunc" function to obtain the return type of function "idx".
   * "argtypes" is the list of argument types or NULL when there are no
   * arguments.
   * "argcount" may be less than the actual count when only getting the type.
   */
      type_T *
! internal_func_ret_type(int idx, int argcount, type2_T *argtypes)
! {
!     return global_functions[idx].f_retfunc(argcount, argtypes);
  }
  
  /*
--- 2728,2752 ----
  
  /*
   * Call the "f_retfunc" function to obtain the return type of function "idx".
+  * "decl_type" is set to the declared type.
   * "argtypes" is the list of argument types or NULL when there are no
   * arguments.
   * "argcount" may be less than the actual count when only getting the type.
   */
      type_T *
! internal_func_ret_type(
!       int         idx,
!       int         argcount,
!       type2_T     *argtypes,
!       type_T      **decl_type)
! {
!     type_T *ret;
! 
!     *decl_type = NULL;
!     ret = global_functions[idx].f_retfunc(argcount, argtypes, decl_type);
!     if (*decl_type == NULL)
!       *decl_type = ret;
!     return ret;
  }
  
  /*
*** ../vim-8.2.4278/src/proto/evalfunc.pro      2022-01-31 14:59:33.522943638 
+0000
--- src/proto/evalfunc.pro      2022-02-01 12:09:43.661022852 +0000
***************
*** 6,12 ****
  char *internal_func_name(int idx);
  int internal_func_check_arg_types(type2_T *types, int idx, int argcount, 
cctx_T *cctx);
  void internal_func_get_argcount(int idx, int *argcount, int *min_argcount);
! type_T *internal_func_ret_type(int idx, int argcount, type2_T *argtypes);
  int internal_func_is_map(int idx);
  int check_internal_func(int idx, int argcount);
  int call_internal_func(char_u *name, int argcount, typval_T *argvars, 
typval_T *rettv);
--- 6,12 ----
  char *internal_func_name(int idx);
  int internal_func_check_arg_types(type2_T *types, int idx, int argcount, 
cctx_T *cctx);
  void internal_func_get_argcount(int idx, int *argcount, int *min_argcount);
! type_T *internal_func_ret_type(int idx, int argcount, type2_T *argtypes, 
type_T **decl_type);
  int internal_func_is_map(int idx);
  int check_internal_func(int idx, int argcount);
  int call_internal_func(char_u *name, int argcount, typval_T *argvars, 
typval_T *rettv);
*** ../vim-8.2.4278/src/vim9instr.c     2022-01-27 16:36:25.419543625 +0000
--- src/vim9instr.c     2022-02-01 12:02:35.239710761 +0000
***************
*** 1078,1084 ****
  
      // Get the member type and the declared member type from all the items on
      // the stack.
!     member_type = get_member_type_from_stack(count, 1, &decl_member_type, 
cctx);
      type = get_list_type(member_type, cctx->ctx_type_list);
      decl_type = get_list_type(decl_member_type, cctx->ctx_type_list);
  
--- 1078,1085 ----
  
      // Get the member type and the declared member type from all the items on
      // the stack.
!     member_type = get_member_type_from_stack(count, 1,
!                                                     &decl_member_type, cctx);
      type = get_list_type(member_type, cctx->ctx_type_list);
      decl_type = get_list_type(decl_member_type, cctx->ctx_type_list);
  
***************
*** 1277,1282 ****
--- 1278,1284 ----
      type2_T   shuffled_argtypes[MAX_FUNC_ARGS];
      type2_T   *maptype = NULL;
      type_T    *type;
+     type_T    *decl_type;
  
      RETURN_OK_IF_SKIP(cctx);
      argoff = check_internal_func(func_idx, argcount);
***************
*** 1327,1334 ****
  
      // Drop the argument types and push the return type.
      stack->ga_len -= argcount;
!     type = internal_func_ret_type(func_idx, argcount, argtypes);
!     if (push_type_stack(cctx, type) == FAIL)
        return FAIL;
  
      if (maptype != NULL && maptype[0].type_decl->tt_member != NULL
--- 1329,1336 ----
  
      // Drop the argument types and push the return type.
      stack->ga_len -= argcount;
!     type = internal_func_ret_type(func_idx, argcount, argtypes, &decl_type);
!     if (push_type_stack2(cctx, type, decl_type) == FAIL)
        return FAIL;
  
      if (maptype != NULL && maptype[0].type_decl->tt_member != NULL
***************
*** 1351,1357 ****
      type_T    *expected;
  
      // Caller already checked that list_type is a list.
!     list_type = get_type_on_stack(cctx, 1);
      item_type = get_type_on_stack(cctx, 0);
      expected = list_type->tt_member;
      if (need_type(item_type, expected, -1, 0, cctx, FALSE, FALSE) == FAIL)
--- 1353,1361 ----
      type_T    *expected;
  
      // Caller already checked that list_type is a list.
!     // For checking the item type we use the declared type of the list and the
!     // current type of the added item, adding a string to [1, 2] is OK.
!     list_type = get_decl_type_on_stack(cctx, 1);
      item_type = get_type_on_stack(cctx, 0);
      expected = list_type->tt_member;
      if (need_type(item_type, expected, -1, 0, cctx, FALSE, FALSE) == FAIL)
*** ../vim-8.2.4278/src/vim9type.c      2022-01-16 18:06:17.723808427 +0000
--- src/vim9type.c      2022-02-01 11:49:10.269103179 +0000
***************
*** 357,364 ****
  
            if (idx >= 0)
            {
                internal_func_get_argcount(idx, &argcount, &min_argcount);
!               member_type = internal_func_ret_type(idx, 0, NULL);
            }
            else
                ufunc = find_func(name, FALSE);
--- 357,366 ----
  
            if (idx >= 0)
            {
+               type_T *decl_type;  // unused
+ 
                internal_func_get_argcount(idx, &argcount, &min_argcount);
!               member_type = internal_func_ret_type(idx, 0, NULL, &decl_type);
            }
            else
                ufunc = find_func(name, FALSE);
***************
*** 1244,1250 ****
  }
  
  /*
!  * Get the type from the type stack.  If "offset" is zero the one at the top,
   * if "offset" is one the type above that, etc.
   * Returns &t_unknown if there is no such stack entry.
   */
--- 1246,1253 ----
  }
  
  /*
!  * Get the current type from the type stack.  If "offset" is zero the one at
!  * the top,
   * if "offset" is one the type above that, etc.
   * Returns &t_unknown if there is no such stack entry.
   */
***************
*** 1260,1265 ****
--- 1263,1285 ----
  }
  
  /*
+  * Get the declared type from the type stack.  If "offset" is zero the one at
+  * the top,
+  * if "offset" is one the type above that, etc.
+  * Returns &t_unknown if there is no such stack entry.
+  */
+     type_T *
+ get_decl_type_on_stack(cctx_T *cctx, int offset)
+ {
+     garray_T  *stack = &cctx->ctx_type_stack;
+ 
+     if (offset + 1 > stack->ga_len)
+       return &t_unknown;
+     return (((type2_T *)stack->ga_data) + stack->ga_len - offset - 1)
+                                                                  ->type_decl;
+ }
+ 
+ /*
   * Get the member type of a dict or list from the items on the stack of 
"cctx".
   * The declared type is stored in "decl_type".
   * For a list "skip" is 1, for a dict "skip" is 2, keys are skipped.
*** ../vim-8.2.4278/src/proto/vim9type.pro      2022-01-16 18:06:17.723808427 
+0000
--- src/proto/vim9type.pro      2022-02-01 11:49:15.473032245 +0000
***************
*** 25,30 ****
--- 25,31 ----
  int push_type_stack2(cctx_T *cctx, type_T *type, type_T *decl_type);
  void set_type_on_stack(cctx_T *cctx, type_T *type, int offset);
  type_T *get_type_on_stack(cctx_T *cctx, int offset);
+ type_T *get_decl_type_on_stack(cctx_T *cctx, int offset);
  type_T *get_member_type_from_stack(int count, int skip, type_T **decl_type, 
cctx_T *cctx);
  char *vartype_name(vartype_T type);
  char *type_name(type_T *type, char **tofree);
*** ../vim-8.2.4278/src/testdir/test_vim9_builtin.vim   2022-01-31 
17:39:45.394105533 +0000
--- src/testdir/test_vim9_builtin.vim   2022-02-01 11:52:59.913486613 +0000
***************
*** 77,83 ****
  
  def Test_add()
    v9.CheckDefAndScriptFailure(['add({}, 1)'], ['E1013: Argument 1: type 
mismatch, expected list<any> but got dict<unknown>', 'E1226: List or Blob 
required for argument 1'])
!   v9.CheckDefFailure(['add([1], "a")'], 'E1012: Type mismatch; expected 
number but got string')
  
    var lines =<< trim END
      vim9script
--- 77,88 ----
  
  def Test_add()
    v9.CheckDefAndScriptFailure(['add({}, 1)'], ['E1013: Argument 1: type 
mismatch, expected list<any> but got dict<unknown>', 'E1226: List or Blob 
required for argument 1'])
!   v9.CheckDefExecFailure([
!         'var ln: list<number> = [1]',
!         'add(ln, "a")'],
!         'E1012: Type mismatch; expected number but got string')
!   assert_equal([1, 'a'], add([1], 'a'))
!   assert_equal(0z1234, add(0z12, 0x34))
  
    var lines =<< trim END
      vim9script
***************
*** 2804,2809 ****
--- 2809,2817 ----
    v9.CheckDefAndScriptFailure(['range("a")'], ['E1013: Argument 1: type 
mismatch, expected number but got string', 'E1210: Number required for argument 
1'])
    v9.CheckDefAndScriptFailure(['range(10, "b")'], ['E1013: Argument 2: type 
mismatch, expected number but got string', 'E1210: Number required for argument 
2'])
    v9.CheckDefAndScriptFailure(['range(10, 20, "c")'], ['E1013: Argument 3: 
type mismatch, expected number but got string', 'E1210: Number required for 
argument 3'])
+ 
+   # returns a list<number> but it's not declared as such
+   assert_equal(['x', 'x'], range(2)->map((i, v) => 'x'))
  enddef
  
  def Test_readdir()
***************
*** 2980,2985 ****
--- 2988,2997 ----
    var d2: any = {1: 'a', 2: 'b', 3: 'c'}
    remove(d2, 2)
    assert_equal({1: 'a', 3: 'c'}, d2)
+ 
+   # using declared type
+   var x: string = range(2)->extend(['x'])->remove(2)
+   assert_equal('x', x)
  enddef
  
  def Test_remove_return_type()
*** ../vim-8.2.4278/src/version.c       2022-02-01 10:15:56.935952340 +0000
--- src/version.c       2022-02-01 12:09:38.705098802 +0000
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4279,
  /**/

-- 
Back off man, I'm a scientist.
              -- Peter, Ghostbusters

 /// Bram Moolenaar -- [email protected] -- 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220201121303.1EDF01C1918%40moolenaar.net.

Raspunde prin e-mail lui