To: vim_dev@googlegroups.com Subject: Patch 8.2.5167 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.5167 Problem: get(Fn, 'name') on funcref returns special byte code. Solution: Use the printable name. Files: src/evalfunc.c, src/testdir/test_getvar.vim *** ../vim-8.2.5166/src/evalfunc.c 2022-06-23 12:04:42.316267504 +0100 --- src/evalfunc.c 2022-06-27 11:45:15.589133775 +0100 *************** *** 4719,4737 **** if (pt != NULL) { char_u *what = tv_get_string(&argvars[1]); - char_u *n; if (STRCMP(what, "func") == 0 || STRCMP(what, "name") == 0) { rettv->v_type = (*what == 'f' ? VAR_FUNC : VAR_STRING); ! n = partial_name(pt); ! if (n == NULL) rettv->vval.v_string = NULL; else { - rettv->vval.v_string = vim_strsave(n); if (rettv->v_type == VAR_FUNC) ! func_ref(rettv->vval.v_string); } } else if (STRCMP(what, "dict") == 0) --- 4719,4741 ---- if (pt != NULL) { char_u *what = tv_get_string(&argvars[1]); if (STRCMP(what, "func") == 0 || STRCMP(what, "name") == 0) { + char_u *name = partial_name(pt); + rettv->v_type = (*what == 'f' ? VAR_FUNC : VAR_STRING); ! if (name == NULL) rettv->vval.v_string = NULL; else { if (rettv->v_type == VAR_FUNC) ! func_ref(name); ! if (*what == 'n' && pt->pt_name == NULL ! && pt->pt_func != NULL) ! // use instead of the byte code ! name = printable_func_name(pt->pt_func); ! rettv->vval.v_string = vim_strsave(name); } } else if (STRCMP(what, "dict") == 0) *** ../vim-8.2.5166/src/testdir/test_getvar.vim 2020-08-12 17:50:31.879655802 +0100 --- src/testdir/test_getvar.vim 2022-06-27 11:37:26.484840134 +0100 *************** *** 134,144 **** --- 134,153 ---- call assert_equal([], get(l:L, 'args')) endfunc + func s:FooBar() + endfunc + " get({func}, {what} [, {default}]) func Test_get_func() let l:F = function('tr') call assert_equal('tr', get(l:F, 'name')) call assert_equal(l:F, get(l:F, 'func')) + + let Fb_func = function('s:FooBar') + call assert_match('\d\+_FooBar', get(Fb_func, 'name')) + let Fb_ref = funcref('s:FooBar') + call assert_match('\d\+_FooBar', get(Fb_ref, 'name')) + call assert_equal({'func has': 'no dict'}, get(l:F, 'dict', {'func has': 'no dict'})) call assert_equal(0, get(l:F, 'dict')) call assert_equal([], get(l:F, 'args')) *** ../vim-8.2.5166/src/version.c 2022-06-26 18:17:44.610514004 +0100 --- src/version.c 2022-06-27 11:38:40.512737613 +0100 *************** *** 737,738 **** --- 737,740 ---- { /* Add new patch number below this line */ + /**/ + 5167, /**/ -- hundred-and-one symptoms of being an internet addict: 11. You find yourself typing "com" after every period when using a word processor.com /// 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 ///