From bfd65589d9b6bd5fd2c8ee768d1427469bd61ead Mon Sep 17 00:00:00 2001 From: Bram Moolenaar <Bram@vim.org> Date: Mon, 13 Jul 2020 18:18:00 +0200 Subject: [PATCH] patch 8.2.1200: Vim9: cannot disassemble a lambda function Problem: Vim9: cannot disassemble a lambda function. Solution: Recognize "<lambda>123" as a function name. --- src/testdir/test_vim9_disassemble.vim | 13 +++++++++++++ src/version.c | 2 ++ src/vim9execute.c | 9 ++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim index 6cde5dda71..f1f943ecb8 100644 --- a/src/testdir/test_vim9_disassemble.vim +++ b/src/testdir/test_vim9_disassemble.vim @@ -664,6 +664,19 @@ def Test_disassemble_lambda() '\d PCALL (argc 1)\_s*' .. '\d RETURN', instr) + + let name = substitute(instr, '.*\(<lambda>\d\+\).*', '\1', '') + instr = execute('disassemble ' .. name) + assert_match('<lambda>\d\+\_s*' .. + 'return "X" .. a .. "X"\_s*' .. + '\d PUSHS "X"\_s*' .. + '\d LOAD arg\[-1\]\_s*' .. + '\d 2STRING stack\[-1\]\_s*' .. + '\d CONCAT\_s*' .. + '\d PUSHS "X"\_s*' .. + '\d CONCAT\_s*' .. + '\d RETURN', + instr) enddef def AndOr(arg: any): string diff --git a/src/version.c b/src/version.c index 21ff2bc9ea..87eda28b43 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1200, /**/ 1199, /**/ diff --git a/src/vim9execute.c b/src/vim9execute.c index 544c4226b2..5fdbfbf518 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -2397,7 +2397,14 @@ ex_disassemble(exarg_T *eap) int prev_current = 0; int is_global = FALSE; - fname = trans_function_name(&arg, &is_global, FALSE, + if (STRNCMP(arg, "<lambda>", 8) == 0) + { + arg += 8; + (void)getdigits(&arg); + fname = vim_strnsave(eap->arg, arg - eap->arg); + } + else + fname = trans_function_name(&arg, &is_global, FALSE, TFN_INT | TFN_QUIET | TFN_NO_AUTOLOAD, NULL, NULL); if (fname == NULL) { -- GitLab