To: vim_dev@googlegroups.com Subject: Patch 8.2.3322 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3322 Problem: Vim9: checking type of dict does not check member type. Solution: When getting the type of a typval use dv_type and lv_type. (closes #8732) Files: src/vim9type.c, src/testdir/test_vim9_builtin.vim *** ../vim-8.2.3321/src/vim9type.c 2021-08-09 19:59:01.446811234 +0200 --- src/vim9type.c 2021-08-09 22:13:05.501879011 +0200 *************** *** 274,283 **** list_T *l = tv->vval.v_list; listitem_T *li; ! if (l == NULL || l->lv_first == NULL) return &t_list_empty; if (!do_member) return &t_list_any; if (l->lv_first == &range_list_item) return &t_list_number; if (l->lv_copyID == copyID) --- 274,285 ---- list_T *l = tv->vval.v_list; listitem_T *li; ! if (l == NULL || (l->lv_first == NULL && l->lv_type == NULL)) return &t_list_empty; if (!do_member) return &t_list_any; + if (l->lv_type != NULL) + return l->lv_type; if (l->lv_first == &range_list_item) return &t_list_number; if (l->lv_copyID == copyID) *************** *** 299,308 **** typval_T *value; dict_T *d = tv->vval.v_dict; ! if (d == NULL || d->dv_hashtab.ht_used == 0) return &t_dict_empty; if (!do_member) return &t_dict_any; if (d->dv_copyID == copyID) // avoid recursion return &t_dict_any; --- 301,312 ---- typval_T *value; dict_T *d = tv->vval.v_dict; ! if (d == NULL || (d->dv_hashtab.ht_used == 0 && d->dv_type == NULL)) return &t_dict_empty; if (!do_member) return &t_dict_any; + if (d->dv_type != NULL) + return d->dv_type; if (d->dv_copyID == copyID) // avoid recursion return &t_dict_any; *** ../vim-8.2.3321/src/testdir/test_vim9_builtin.vim 2021-08-08 14:41:48.723930691 +0200 --- src/testdir/test_vim9_builtin.vim 2021-08-09 22:13:28.157821788 +0200 *************** *** 922,927 **** --- 922,933 ---- END CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0) CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1) + + lines =<< trim END + var d: dict + extend(d, {b: 0}) + END + CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict but got dict', 2) enddef func g:ExtendList(l) *************** *** 947,952 **** --- 953,964 ---- END CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0) CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1) + + lines =<< trim END + var l: list + extend(l, [0]) + END + CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list but got list', 2) enddef def Test_extend_return_type() *** ../vim-8.2.3321/src/version.c 2021-08-09 21:04:20.948157277 +0200 --- src/version.c 2021-08-09 22:03:35.107316137 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3322, /**/ -- MARTHA'S WAY: Don't throw out all that leftover wine. Freeze into ice cubes for future use in casseroles and sauces. MY WAY: What leftover wine? /// Bram Moolenaar -- Bram@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 ///