mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
patch 9.1.2111: Vim9: no error for elseif/else after else
Problem: Vim9: no error for elseif/else after else Solution: Report an error (Hirohito Higashi) closes: #19263 Signed-off-by: Hirohito Higashi <h.east.727@gmail.com> Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
b73565d89d
commit
271a46811e
@@ -1995,6 +1995,25 @@ def Test_if_elseif_else_fails()
|
||||
END
|
||||
v9.CheckDefFailure(lines, 'E488:')
|
||||
|
||||
|
||||
lines =<< trim END
|
||||
if true
|
||||
else
|
||||
else
|
||||
endif
|
||||
END
|
||||
v9.CheckSourceDefFailure(lines, 'E583:')
|
||||
|
||||
lines =<< trim END
|
||||
var a = 3
|
||||
if a == 2
|
||||
else
|
||||
elseif true
|
||||
else
|
||||
endif
|
||||
END
|
||||
v9.CheckSourceDefFailure(lines, 'E584:')
|
||||
|
||||
lines =<< trim END
|
||||
var cond = true
|
||||
if cond
|
||||
|
||||
@@ -734,6 +734,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2111,
|
||||
/**/
|
||||
2110,
|
||||
/**/
|
||||
|
||||
@@ -596,6 +596,11 @@ compile_elseif(char_u *arg, cctx_T *cctx)
|
||||
emsg(_(e_elseif_without_if));
|
||||
return NULL;
|
||||
}
|
||||
if (scope->se_u.se_if.is_seen_else)
|
||||
{
|
||||
emsg(_(e_elseif_after_else));
|
||||
return NULL;
|
||||
}
|
||||
unwind_locals(cctx, scope->se_local_count, TRUE);
|
||||
if (!cctx->ctx_had_return && !cctx->ctx_had_throw)
|
||||
// the previous if block didn't end in a "return" or a "throw"
|
||||
@@ -745,6 +750,11 @@ compile_else(char_u *arg, cctx_T *cctx)
|
||||
emsg(_(e_else_without_if));
|
||||
return NULL;
|
||||
}
|
||||
if (scope->se_u.se_if.is_seen_else)
|
||||
{
|
||||
emsg(_(e_multiple_else));
|
||||
return NULL;
|
||||
}
|
||||
unwind_locals(cctx, scope->se_local_count, TRUE);
|
||||
if (!cctx->ctx_had_return && !cctx->ctx_had_throw)
|
||||
// the previous if block didn't end in a "return" or a "throw"
|
||||
|
||||
Reference in New Issue
Block a user