To: vim_dev@googlegroups.com Subject: Patch 9.0.0557 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0557 Problem: Valgrind reports possibly leaked memory. Solution: Move the problematic test function to the "fails" test file to avoid obscuring real memory leaks. Files: src/testdir/test_vim9_func.vim, src/testdir/test_vim9_fails.vim *** ../vim-9.0.0556/src/testdir/test_vim9_func.vim 2022-09-23 12:44:19.795794418 +0100 --- src/testdir/test_vim9_func.vim 2022-09-23 16:08:50.353624704 +0100 *************** *** 3532,3565 **** v9.CheckDefAndScriptSuccess(lines) enddef - " Using "idx" from a legacy global function does not work. - " This caused a crash when called from legacy context. - func Test_partial_call_fails() - let lines =<< trim END - vim9script - - var l = ['a', 'b', 'c'] - def Iter(container: any): any - var idx = -1 - var obj = {state: container} - def g:NextItem__(self: dict): any - ++idx - return self.state[idx] - enddef - obj.__next__ = function('g:NextItem__', [obj]) - return obj - enddef - - var it = Iter(l) - echo it.__next__() - END - call writefile(lines, 'XpartialCall', 'D') - try - source XpartialCall - catch /E1248:/ - endtry - endfunc - def Test_cmd_modifier() tab echo '0' v9.CheckDefFailure(['5tab echo 3'], 'E16:') --- 3532,3537 ---- *** ../vim-9.0.0556/src/testdir/test_vim9_fails.vim 2021-12-04 14:58:15.000000000 +0000 --- src/testdir/test_vim9_fails.vim 2022-09-23 15:54:49.332740801 +0100 *************** *** 26,28 **** --- 26,62 ---- endif enddef + " Using "idx" from a legacy global function does not work. + " This caused a crash when called from legacy context. + " This creates a dict that contains a partial that refers to the dict, causing + " valgrind to report "possibly leaked memory". + func Test_partial_call_fails() + let lines =<< trim END + vim9script + + var l = ['a', 'b', 'c'] + def Iter(container: any): any + var idx = -1 + var obj = {state: container} + def g:NextItem__(self: dict): any + ++idx + return self.state[idx] + enddef + obj.__next__ = function('g:NextItem__', [obj]) + return obj + enddef + + var it = Iter(l) + echo it.__next__() + END + call writefile(lines, 'XpartialCall', 'D') + let caught = 'no' + try + source XpartialCall + catch /E1248:/ + let caught = 'yes' + endtry + call assert_equal('yes', caught) + delfunc g:NextItem__ + endfunc + *** ../vim-9.0.0556/src/version.c 2022-09-23 13:27:47.930575182 +0100 --- src/version.c 2022-09-23 15:48:12.562838114 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 557, /**/ -- hundred-and-one symptoms of being an internet addict: 142. You dream about creating the world's greatest web site. /// 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 ///