To: vim_dev@googlegroups.com Subject: Patch 8.2.1256 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1256 Problem: Vim9: type wrong after getting dict item in lambda. Solution: Set the type to "any" after enforcing dict type. (closes #6491) Files: src/vim9compile.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1255/src/vim9compile.c 2020-07-19 19:47:32.093046796 +0200 --- src/vim9compile.c 2020-07-20 22:04:22.750490724 +0200 *************** *** 3797,3805 **** { if ((*typep)->tt_type == VAR_DICT) *typep = (*typep)->tt_member; ! else if (need_type(*typep, &t_dict_any, -2, cctx, FALSE) ! == FAIL) ! return FAIL; if (may_generate_2STRING(-1, cctx) == FAIL) return FAIL; if (generate_instr_drop(cctx, ISN_MEMBER, 1) == FAIL) --- 3797,3808 ---- { if ((*typep)->tt_type == VAR_DICT) *typep = (*typep)->tt_member; ! else ! { ! if (need_type(*typep, &t_dict_any, -2, cctx, FALSE) == FAIL) ! return FAIL; ! *typep = &t_any; ! } if (may_generate_2STRING(-1, cctx) == FAIL) return FAIL; if (generate_instr_drop(cctx, ISN_MEMBER, 1) == FAIL) *** ../vim-8.2.1255/src/testdir/test_vim9_expr.vim 2020-07-19 19:47:32.093046796 +0200 --- src/testdir/test_vim9_expr.vim 2020-07-20 22:07:40.458279015 +0200 *************** *** 1176,1181 **** --- 1176,1185 ---- let dl = [{'key': 0}, {'key': 22}]->filter({ _, v -> v['key'] }) assert_equal([{'key': 22}], dl) + dl = [{'key': 12}, {'foo': 34}] + assert_equal([{'key': 12}], filter(dl, + {_, v -> has_key(v, 'key') ? v['key'] == 12 : 0})) + call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:') enddef *** ../vim-8.2.1255/src/version.c 2020-07-20 21:31:01.272823437 +0200 --- src/version.c 2020-07-20 22:05:37.634424568 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1256, /**/ -- The real trick is this: to keep the lines as short as possible and keep the size the same yet free from the need for hyphena- Dammit!! (Matthew Winn) /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///