Skip to content

Commit 968a5b6

Browse files
committed
patch 8.2.3003: Vim9: closure compiled with wrong compile type
Problem: Vim9: closure compiled with wrong compile type. Solution: Use COMPILE_TYPE() when calling a function. (closes #8384)
1 parent affd0bc commit 968a5b6

3 files changed

Lines changed: 30 additions & 5 deletions

File tree

src/testdir/test_debugger.vim

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,33 @@ func Test_Backtrace_DefFunction()
932932
call delete('Xtest2.vim')
933933
endfunc
934934

935+
func Test_debug_def_function()
936+
CheckCWD
937+
let file =<< trim END
938+
vim9script
939+
def g:Func()
940+
var n: number
941+
def Closure(): number
942+
return n + 3
943+
enddef
944+
n += Closure()
945+
echo 'result: ' .. n
946+
enddef
947+
END
948+
call writefile(file, 'Xtest.vim')
949+
950+
let buf = RunVimInTerminal('-S Xtest.vim', {})
951+
952+
call RunDbgCmd(buf,
953+
\ ':debug call Func()',
954+
\ ['cmd: call Func()'])
955+
call RunDbgCmd(buf, 'next', ['result: 3'])
956+
call term_sendkeys(buf, "\r")
957+
958+
call StopVimInTerminal(buf)
959+
call delete('Xtest.vim')
960+
endfunc
961+
935962
func Test_debug_backtrace_level()
936963
CheckCWD
937964
let lines =<< trim END

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
3003,
753755
/**/
754756
3002,
755757
/**/

src/vim9execute.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,8 @@ call_ufunc(
752752
int error;
753753
int idx;
754754
int did_emsg_before = did_emsg;
755-
compiletype_T compile_type = CT_NONE;
755+
compiletype_T compile_type = COMPILE_TYPE(ufunc);
756756

757-
#ifdef FEAT_PROFILE
758-
if (do_profiling == PROF_YES && ufunc->uf_profiling)
759-
compile_type = CT_PROFILE;
760-
#endif
761757
if (func_needs_compiling(ufunc, compile_type)
762758
&& compile_def_function(ufunc, FALSE, compile_type, NULL)
763759
== FAIL)

0 commit comments

Comments
 (0)