mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
Merge pull request #20467 from zeertzjq/vim-8.2.2316
vim-patch:8.2.2316: Vim9: cannot list a lambda function
This commit is contained in:
commit
a93ff5fc69
@ -1983,7 +1983,14 @@ void ex_function(exarg_T *eap)
|
|||||||
// s:func script-local function name
|
// s:func script-local function name
|
||||||
// g:func global function name, same as "func"
|
// g:func global function name, same as "func"
|
||||||
p = eap->arg;
|
p = eap->arg;
|
||||||
name = (char *)trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL);
|
if (strncmp(p, "<lambda>", 8) == 0) {
|
||||||
|
p += 8;
|
||||||
|
(void)getdigits(&p, false, 0);
|
||||||
|
name = xstrndup(eap->arg, (size_t)(p - eap->arg));
|
||||||
|
CLEAR_FIELD(fudi);
|
||||||
|
} else {
|
||||||
|
name = (char *)trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL);
|
||||||
|
}
|
||||||
paren = (vim_strchr(p, '(') != NULL);
|
paren = (vim_strchr(p, '(') != NULL);
|
||||||
if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) {
|
if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) {
|
||||||
// Return on an invalid expression in braces, unless the expression
|
// Return on an invalid expression in braces, unless the expression
|
||||||
|
@ -17,6 +17,7 @@ local clear = helpers.clear
|
|||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local exc_exec = helpers.exc_exec
|
local exc_exec = helpers.exc_exec
|
||||||
local exec = helpers.exec
|
local exec = helpers.exec
|
||||||
|
local exec_capture = helpers.exec_capture
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
@ -247,3 +248,16 @@ describe("uncaught exception", function()
|
|||||||
eq('123', eval('result'))
|
eq('123', eval('result'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('lambda function', function()
|
||||||
|
before_each(clear)
|
||||||
|
|
||||||
|
it('can be shown using :function followed by <lambda> #20466', function()
|
||||||
|
command('let A = {-> 1}')
|
||||||
|
local num = exec_capture('echo A'):match("function%('<lambda>(%d+)'%)")
|
||||||
|
eq(([[
|
||||||
|
function <lambda>%s(...)
|
||||||
|
1 return 1
|
||||||
|
endfunction]]):format(num), exec_capture(('function <lambda>%s'):format(num)))
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user