0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.1191: Vim9: crash when function calls itself

Problem:    Vim9: crash when function calls itself.
Solution:   Add status UF_COMPILING. (closes #6441)
This commit is contained in:
Bram Moolenaar
2020-07-12 17:31:09 +02:00
parent eb6880b6eb
commit 985116ae0b
4 changed files with 17 additions and 0 deletions

View File

@@ -1539,6 +1539,7 @@ typedef struct funccall_S funccall_T;
typedef enum { typedef enum {
UF_NOT_COMPILED, UF_NOT_COMPILED,
UF_TO_BE_COMPILED, UF_TO_BE_COMPILED,
UF_COMPILING,
UF_COMPILED UF_COMPILED
} def_status_T; } def_status_T;

View File

@@ -999,5 +999,17 @@ func Test_silent_echo()
call delete('XTest_silent_echo') call delete('XTest_silent_echo')
endfunc endfunc
def Fibonacci(n: number): number
if n < 2
return n
else
return Fibonacci(n - 1) + Fibonacci(n - 2)
endif
enddef
def Test_recursive_call()
assert_equal(6765, Fibonacci(20))
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1191,
/**/ /**/
1190, 1190,
/**/ /**/

View File

@@ -6802,6 +6802,8 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
else if (add_def_function(ufunc) == FAIL) else if (add_def_function(ufunc) == FAIL)
return FAIL; return FAIL;
ufunc->uf_def_status = UF_COMPILING;
CLEAR_FIELD(cctx); CLEAR_FIELD(cctx);
cctx.ctx_ufunc = ufunc; cctx.ctx_ufunc = ufunc;
cctx.ctx_lnum = -1; cctx.ctx_lnum = -1;