get() on funcref() gives leading 0x80fd52 on <SNR> function references

7 views
Skip to first unread message

minx ab

unread,
Jun 27, 2022, 4:54:38 AM6/27/22
to vim...@vim.org
Not sure if this is a bug or not.

Example:
---------------------------------------------------

fun! s:Foo()
endfun

fun! s:Bar()
endfun

let name_foo = get(function('s:Foo'), 'name')
let name_bar = get(funcref('s:Bar'), 'name')

echo printf('"%s" vs "%s"', name_foo, name_bar)

exe "function " . name_foo
exe "function " . name_bar

---------------------------------------------------

Result:
---------------------------------------------------

"<SNR>116_Foo" vs "<80><fd>R116_Bar"
function <SNR>116_Foo()
endfunction
function <SNR>116_Bar()
endfunction

---------------------------------------------------

When the Funcref is a funcref() instead of function() the
"<SNR>" part is "0x80fd52".

As one can use the the name starting with 0x80 for looking
up by :function, I'm not sure if it is a bug or a feature.

It looks like a signature of sorts and can perhaps be used
to reliably distinguish the two from one another?

Best regards,
M



Bram Moolenaar

unread,
Jun 27, 2022, 6:46:24 AM6/27/22
to vim...@googlegroups.com, vim...@vim.org
Yes, this looks like a bug. When requesting the function name there is
no need to keep the internal coding of the script-local function name.
I'll make a patch for that.


--
The Feynman problem solving Algorithm:
1) Write down the problem
2) Think real hard
3) Write down the answer

/// Bram Moolenaar -- Br...@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 ///
Reply all
Reply to author
Forward
0 new messages