Skip to content

Commit 17d868b

Browse files
committed
patch 8.2.3066: Vim9: debugging lambda does not work
Problem: Vim9: debugging lambda does not work. Solution: Use the compile type of the function when compiling a lambda. (closes #8412)
1 parent 577dc93 commit 17d868b

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/testdir/test_debugger.vim

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ func Test_Backtrace_DefFunction()
932932
call delete('Xtest2.vim')
933933
endfunc
934934

935-
func Test_debug_DefFunction()
935+
func Test_debug_def_and_legacy_function()
936936
CheckCWD
937937
let file =<< trim END
938938
vim9script
@@ -1068,6 +1068,33 @@ func Test_debug_def_function()
10681068
call delete('Xtest.vim')
10691069
endfunc
10701070

1071+
func Test_debug_def_function_with_lambda()
1072+
CheckCWD
1073+
let lines =<< trim END
1074+
vim9script
1075+
def g:Func()
1076+
var s = 'a'
1077+
['b']->map((_, v) => s)
1078+
echo "done"
1079+
enddef
1080+
breakadd func 2 g:Func
1081+
END
1082+
call writefile(lines, 'XtestLambda.vim')
1083+
1084+
let buf = RunVimInTerminal('-S XtestLambda.vim', {})
1085+
1086+
call RunDbgCmd(buf,
1087+
\ ':call g:Func()',
1088+
\ ['function Func', 'line 2: [''b'']->map((_, v) => s)'])
1089+
call RunDbgCmd(buf,
1090+
\ 'next',
1091+
\ ['function Func', 'line 3: echo "done"'])
1092+
1093+
call RunDbgCmd(buf, 'cont')
1094+
call StopVimInTerminal(buf)
1095+
call delete('XtestLambda.vim')
1096+
endfunc
1097+
10711098
func Test_debug_backtrace_level()
10721099
CheckCWD
10731100
let lines =<< trim END

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3066,
758760
/**/
759761
3065,
760762
/**/

src/vim9compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3622,7 +3622,7 @@ compile_lambda(char_u **arg, cctx_T *cctx)
36223622
// compile_return().
36233623
if (ufunc->uf_ret_type->tt_type == VAR_VOID)
36243624
ufunc->uf_ret_type = &t_unknown;
3625-
compile_def_function(ufunc, FALSE, COMPILE_TYPE(ufunc), cctx);
3625+
compile_def_function(ufunc, FALSE, cctx->ctx_compile_type, cctx);
36263626

36273627
// evalarg.eval_tofree_cmdline may have a copy of the last line and "*arg"
36283628
// points into it. Point to the original line to avoid a dangling pointer.

0 commit comments

Comments
 (0)