To: vim_dev@googlegroups.com Subject: Patch 8.2.3326 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3326 Problem: Vim9: no error passing an empty list of the wrong type. Solution: Use ISN_SETTYPE also for "list". (closes #8732) Files: src/vim9compile.c, src/testdir/test_vim9_func.vim, src/testdir/test_vim9_disassemble.vim *** ../vim-8.2.3325/src/vim9compile.c 2021-08-10 19:52:57.474235537 +0200 --- src/vim9compile.c 2021-08-10 22:39:26.703543703 +0200 *************** *** 1598,1604 **** // get the member type from all the items on the stack. if (count == 0) ! member = &t_void; else member = get_member_type_from_stack( ((type_T **)stack->ga_data) + stack->ga_len, count, 1, --- 1598,1604 ---- // get the member type from all the items on the stack. if (count == 0) ! member = &t_unknown; else member = get_member_type_from_stack( ((type_T **)stack->ga_data) + stack->ga_len, count, 1, *************** *** 7190,7199 **** && (lhs.lhs_type->tt_type == VAR_DICT || lhs.lhs_type->tt_type == VAR_LIST) && lhs.lhs_type->tt_member != NULL ! && lhs.lhs_type->tt_member != &t_any && lhs.lhs_type->tt_member != &t_unknown) // Set the type in the list or dict, so that it can be checked, ! // also in legacy script. generate_SETTYPE(cctx, lhs.lhs_type); if (generate_store_lhs(cctx, &lhs, instr_count) == FAIL) --- 7190,7204 ---- && (lhs.lhs_type->tt_type == VAR_DICT || lhs.lhs_type->tt_type == VAR_LIST) && lhs.lhs_type->tt_member != NULL ! && !(lhs.lhs_type->tt_member == &t_any ! && oplen > 0 ! && rhs_type != NULL ! && rhs_type->tt_type == lhs.lhs_type->tt_type ! && rhs_type->tt_member != &t_unknown) && lhs.lhs_type->tt_member != &t_unknown) // Set the type in the list or dict, so that it can be checked, ! // also in legacy script. Not for "list = val", then the ! // type of "val" is used. generate_SETTYPE(cctx, lhs.lhs_type); if (generate_store_lhs(cctx, &lhs, instr_count) == FAIL) *** ../vim-8.2.3325/src/testdir/test_vim9_func.vim 2021-08-08 19:07:32.924667679 +0200 --- src/testdir/test_vim9_func.vim 2021-08-10 22:46:52.306299337 +0200 *************** *** 2930,2935 **** --- 2930,2956 ---- CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:') enddef + def Test_list_any_type_checked() + var lines =<< trim END + vim9script + def Foo() + --decl-- + Bar(l) + enddef + def Bar(ll: list>) + enddef + Foo() + END + lines[2] = 'var l: list' + CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list> but got list', 2) + + lines[2] = 'var l: list = []' + CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list> but got list', 2) + + lines[2] = 'var l: list = [11]' + CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list> but got list', 2) + enddef + def Test_compile_error() var lines =<< trim END def g:Broken() *** ../vim-8.2.3325/src/testdir/test_vim9_disassemble.vim 2021-08-07 16:30:35.109065179 +0200 --- src/testdir/test_vim9_disassemble.vim 2021-08-10 22:21:27.558644938 +0200 *************** *** 435,440 **** --- 435,441 ---- '\d STORE $1\_s*' .. 'var l: list\_s*' .. '\d NEWLIST size 0\_s*' .. + '\d SETTYPE list\_s*' .. '\d STORE $2\_s*' .. '\[x, y; l\] = g:stringlist\_s*' .. '\d LOADG g:stringlist\_s*' .. *** ../vim-8.2.3325/src/version.c 2021-08-10 21:39:17.041820459 +0200 --- src/version.c 2021-08-10 22:23:37.650290609 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3326, /**/ -- GUEST: He's killed the best man! SECOND GUEST: (holding a limp WOMAN) He's killed my auntie. FATHER: No, please! This is supposed to be a happy occasion! Let's not bicker and argue about who killed who ... "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///