mirror of
https://github.com/vim/vim.git
synced 2025-09-04 21:33:48 -04:00
patch 9.0.2172: Vim9: compiling :defer may fail
Problem: Vim9: compiling :defer may fail Solution: compile defer, when ctx_skip is not SKIP_YES compiling defer fails in an if statement with false condition, so check the ctx_skip value when compiling :defer fixes: #13698 closes: #13702 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
535e8f5941
commit
a185a31fc0
@ -4783,6 +4783,19 @@ def Test_multidefer_with_exception()
|
|||||||
v9.CheckSourceSuccess(lines)
|
v9.CheckSourceSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
" Test for using ":defer" inside an if statement with a false condition
|
||||||
|
def Test_defer_skipped()
|
||||||
|
var lines =<< trim END
|
||||||
|
def Foo()
|
||||||
|
if false
|
||||||
|
defer execute('echow "hello"', "")
|
||||||
|
endif
|
||||||
|
enddef
|
||||||
|
defcompile
|
||||||
|
END
|
||||||
|
v9.CheckSourceSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
" Keep this last, it messes up highlighting.
|
" Keep this last, it messes up highlighting.
|
||||||
def Test_substitute_cmd()
|
def Test_substitute_cmd()
|
||||||
new
|
new
|
||||||
|
@ -705,7 +705,7 @@ 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 */
|
||||||
/**/
|
/**/
|
||||||
2171,
|
2172,
|
||||||
/**/
|
/**/
|
||||||
2170,
|
2170,
|
||||||
/**/
|
/**/
|
||||||
|
@ -2020,18 +2020,23 @@ compile_defer(char_u *arg_start, cctx_T *cctx)
|
|||||||
*paren = '(';
|
*paren = '(';
|
||||||
|
|
||||||
// check for function type
|
// check for function type
|
||||||
|
if (cctx->ctx_skip != SKIP_YES)
|
||||||
|
{
|
||||||
type = get_type_on_stack(cctx, 0);
|
type = get_type_on_stack(cctx, 0);
|
||||||
if (type->tt_type != VAR_FUNC)
|
if (type->tt_type != VAR_FUNC)
|
||||||
{
|
{
|
||||||
emsg(_(e_function_name_required));
|
emsg(_(e_function_name_required));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// compile the arguments
|
// compile the arguments
|
||||||
arg = skipwhite(paren + 1);
|
arg = skipwhite(paren + 1);
|
||||||
if (compile_arguments(&arg, cctx, &argcount, CA_NOT_SPECIAL) == FAIL)
|
if (compile_arguments(&arg, cctx, &argcount, CA_NOT_SPECIAL) == FAIL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (cctx->ctx_skip != SKIP_YES)
|
||||||
|
{
|
||||||
if (func_idx >= 0)
|
if (func_idx >= 0)
|
||||||
{
|
{
|
||||||
type2_T *argtypes = NULL;
|
type2_T *argtypes = NULL;
|
||||||
@ -2050,6 +2055,7 @@ compile_defer(char_u *arg_start, cctx_T *cctx)
|
|||||||
return NULL;
|
return NULL;
|
||||||
if (generate_DEFER(cctx, defer_var_idx - 1, argcount) == FAIL)
|
if (generate_DEFER(cctx, defer_var_idx - 1, argcount) == FAIL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return skipwhite(arg);
|
return skipwhite(arg);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user