mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1528: Vim9: :endif not found after "if false"
Problem: Vim9: :endif not found after "if false". Solution: When skipping still check for a following command. (closes #6797)
This commit is contained in:
@@ -2122,6 +2122,14 @@ def Test_if_const_expr()
|
|||||||
res = true
|
res = true
|
||||||
endif
|
endif
|
||||||
assert_equal(false, res)
|
assert_equal(false, res)
|
||||||
|
|
||||||
|
# with constant "false" expression may be invalid so long as the syntax is OK
|
||||||
|
if false | eval 0 | endif
|
||||||
|
if false | eval burp + 234 | endif
|
||||||
|
if false | echo burp 234 'asd' | endif
|
||||||
|
if false
|
||||||
|
burp
|
||||||
|
endif
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_if_const_expr_fails()
|
def Test_if_const_expr_fails()
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
1528,
|
||||||
/**/
|
/**/
|
||||||
1527,
|
1527,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -4014,6 +4014,13 @@ compile_expr1(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
|||||||
int ppconst_used = ppconst->pp_used;
|
int ppconst_used = ppconst->pp_used;
|
||||||
char_u *next;
|
char_u *next;
|
||||||
|
|
||||||
|
// Ignore all kinds of errors when not producing code.
|
||||||
|
if (cctx->ctx_skip == SKIP_YES)
|
||||||
|
{
|
||||||
|
skip_expr(arg);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
// Evaluate the first expression.
|
// Evaluate the first expression.
|
||||||
if (compile_expr2(arg, cctx, ppconst) == FAIL)
|
if (compile_expr2(arg, cctx, ppconst) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -6724,17 +6731,8 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
|
|||||||
|
|
||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
|
|
||||||
if (cctx.ctx_skip == SKIP_YES
|
if (cctx.ctx_had_return
|
||||||
&& ea.cmdidx != CMD_if
|
|
||||||
&& ea.cmdidx != CMD_elseif
|
&& ea.cmdidx != CMD_elseif
|
||||||
&& ea.cmdidx != CMD_else
|
|
||||||
&& ea.cmdidx != CMD_endif)
|
|
||||||
{
|
|
||||||
line = (char_u *)"";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ea.cmdidx != CMD_elseif
|
|
||||||
&& ea.cmdidx != CMD_else
|
&& ea.cmdidx != CMD_else
|
||||||
&& ea.cmdidx != CMD_endif
|
&& ea.cmdidx != CMD_endif
|
||||||
&& ea.cmdidx != CMD_endfor
|
&& ea.cmdidx != CMD_endfor
|
||||||
@@ -6742,13 +6740,10 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
|
|||||||
&& ea.cmdidx != CMD_catch
|
&& ea.cmdidx != CMD_catch
|
||||||
&& ea.cmdidx != CMD_finally
|
&& ea.cmdidx != CMD_finally
|
||||||
&& ea.cmdidx != CMD_endtry)
|
&& ea.cmdidx != CMD_endtry)
|
||||||
{
|
|
||||||
if (cctx.ctx_had_return)
|
|
||||||
{
|
{
|
||||||
emsg(_(e_unreachable_code_after_return));
|
emsg(_(e_unreachable_code_after_return));
|
||||||
goto erret;
|
goto erret;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch (ea.cmdidx)
|
switch (ea.cmdidx)
|
||||||
{
|
{
|
||||||
@@ -6845,7 +6840,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
|
|||||||
if (compile_expr0(&p, &cctx) == FAIL)
|
if (compile_expr0(&p, &cctx) == FAIL)
|
||||||
goto erret;
|
goto erret;
|
||||||
|
|
||||||
// drop the return value
|
// drop the result
|
||||||
generate_instr_drop(&cctx, ISN_DROP, 1);
|
generate_instr_drop(&cctx, ISN_DROP, 1);
|
||||||
|
|
||||||
line = skipwhite(p);
|
line = skipwhite(p);
|
||||||
@@ -6859,7 +6854,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
|
|||||||
line = compile_mult_expr(p, ea.cmdidx, &cctx);
|
line = compile_mult_expr(p, ea.cmdidx, &cctx);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// TODO: other commands with an expression argument
|
// TODO: any other commands with an expression argument?
|
||||||
|
|
||||||
case CMD_append:
|
case CMD_append:
|
||||||
case CMD_change:
|
case CMD_change:
|
||||||
@@ -6870,8 +6865,14 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
|
|||||||
goto erret;
|
goto erret;
|
||||||
|
|
||||||
case CMD_SIZE:
|
case CMD_SIZE:
|
||||||
|
if (cctx.ctx_skip != SKIP_YES)
|
||||||
|
{
|
||||||
semsg(_(e_invalid_command_str), ea.cmd);
|
semsg(_(e_invalid_command_str), ea.cmd);
|
||||||
goto erret;
|
goto erret;
|
||||||
|
}
|
||||||
|
// We don't check for a next command here.
|
||||||
|
line = (char_u *)"";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Not recognized, execute with do_cmdline_cmd().
|
// Not recognized, execute with do_cmdline_cmd().
|
||||||
|
Reference in New Issue
Block a user