To: vim_dev@googlegroups.com Subject: Patch 8.2.1152 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1152 Problem: Vim9: function reference is missing script prefix. Solution: Use the actual function name instead of the name searched for in the script context. (closes #6412) Files: src/vim9compile.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.1151/src/vim9compile.c 2020-07-06 23:04:44.829229830 +0200 --- src/vim9compile.c 2020-07-07 22:35:38.042271918 +0200 *************** *** 2676,2682 **** if (ufunc == NULL) return FAIL; ! return generate_PUSHFUNC(cctx, vim_strsave(name), ufunc->uf_func_type); } /* --- 2676,2683 ---- if (ufunc == NULL) return FAIL; ! return generate_PUSHFUNC(cctx, vim_strsave(ufunc->uf_name), ! ufunc->uf_func_type); } /* *** ../vim-8.2.1151/src/testdir/test_vim9_script.vim 2020-07-05 21:38:07.857431843 +0200 --- src/testdir/test_vim9_script.vim 2020-07-07 22:34:29.446459421 +0200 *************** *** 980,985 **** --- 980,1018 ---- delete('Ximport.vim') enddef + " Not exported function that is referenced needs to be accessed by the + " script-local name. + def Test_vim9script_funcref() + let sortlines =<< trim END + vim9script + def Compare(i1: number, i2: number): number + return 1 + enddef + + export def FastSort(): list + return range(5)->sort(Compare) + enddef + END + writefile(sortlines, 'Xsort.vim') + + let lines =<< trim END + vim9script + import FastSort from './Xsort.vim' + def Test() + g:result = FastSort() + enddef + Test() + END + writefile(lines, 'Xscript.vim') + + source Xscript.vim + assert_equal([4, 3, 2, 1, 0], g:result) + + unlet g:result + delete('Xsort.vim') + delete('Xscript.vim') + enddef + def Test_vim9script_reload_delfunc() let first_lines =<< trim END vim9script *** ../vim-8.2.1151/src/version.c 2020-07-07 20:50:35.570759730 +0200 --- src/version.c 2020-07-07 22:29:07.947338232 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1152, /**/ -- For humans, honesty is a matter of degree. Engineers are always honest in matters of technology and human relationships. That's why it's a good idea to keep engineers away from customers, romantic interests, and other people who can't handle the truth. (Scott Adams - The Dilbert principle) /// 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 ///