To: vim_dev@googlegroups.com Subject: Patch 8.2.3766 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3766 Problem: Converting a funcref to a string leaves out "g:", causing the meaning of the name depending on the context. Solution: Prepend "g:" for a global function. Files: src/eval.c, src/testdir/test_functions.vim *** ../vim-8.2.3765/src/eval.c 2021-12-06 11:03:50.946900217 +0000 --- src/eval.c 2021-12-09 16:36:07.414279161 +0000 *************** *** 5006,5012 **** ga_concat(&ga, (char_u *)"function("); if (fname != NULL) { ! ga_concat(&ga, fname); vim_free(fname); } if (pt != NULL && pt->pt_argc > 0) --- 5006,5020 ---- ga_concat(&ga, (char_u *)"function("); if (fname != NULL) { ! // When using uf_name prepend "g:" for a global function. ! if (pt->pt_name == NULL && fname[0] == '\'' ! && vim_isupper(fname[1])) ! { ! ga_concat(&ga, (char_u *)"'g:"); ! ga_concat(&ga, fname + 1); ! } ! else ! ga_concat(&ga, fname); vim_free(fname); } if (pt != NULL && pt->pt_argc > 0) *** ../vim-8.2.3765/src/testdir/test_functions.vim 2021-10-19 11:15:36.118656545 +0100 --- src/testdir/test_functions.vim 2021-12-09 16:39:27.229270064 +0000 *************** *** 2771,2775 **** --- 2771,2780 ---- call assert_fails('call extend(g:, #{bar: { -> "foo" }}, "force")', 'E704:') endfunc + func Test_funcref_to_string() + let Fn = funcref('g:Test_funcref_to_string') + call assert_equal("function('g:Test_funcref_to_string')", string(Fn)) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3765/src/version.c 2021-12-09 14:23:40.265634965 +0000 --- src/version.c 2021-12-09 16:39:52.613136407 +0000 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 3766, /**/ -- hundred-and-one symptoms of being an internet addict: 19. All of your friends have an @ in their names. /// 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 ///