mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.1.0976: Vim9: missing return statement with throw
Problem: Vim9: missing return statement with throw (atitcreate) Solution: Treat a throw statement at the end of an if-else block as a return statement (Yegappan Lakshmanan) fixes: #16312 closes: #16338 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
b0206e9fb5
commit
ab9a8947d7
@@ -602,7 +602,9 @@ compile_elseif(char_u *arg, cctx_T *cctx)
|
||||
return NULL;
|
||||
}
|
||||
unwind_locals(cctx, scope->se_local_count, TRUE);
|
||||
if (!cctx->ctx_had_return)
|
||||
if (!cctx->ctx_had_return && !cctx->ctx_had_throw)
|
||||
// the previous if block didn't end in a "return" or a "throw"
|
||||
// statement.
|
||||
scope->se_u.se_if.is_had_return = FALSE;
|
||||
|
||||
if (cctx->ctx_skip == SKIP_NOT)
|
||||
@@ -749,7 +751,9 @@ compile_else(char_u *arg, cctx_T *cctx)
|
||||
return NULL;
|
||||
}
|
||||
unwind_locals(cctx, scope->se_local_count, TRUE);
|
||||
if (!cctx->ctx_had_return)
|
||||
if (!cctx->ctx_had_return && !cctx->ctx_had_throw)
|
||||
// the previous if block didn't end in a "return" or a "throw"
|
||||
// statement.
|
||||
scope->se_u.se_if.is_had_return = FALSE;
|
||||
scope->se_u.se_if.is_seen_else = TRUE;
|
||||
|
||||
@@ -821,7 +825,9 @@ compile_endif(char_u *arg, cctx_T *cctx)
|
||||
}
|
||||
ifscope = &scope->se_u.se_if;
|
||||
unwind_locals(cctx, scope->se_local_count, TRUE);
|
||||
if (!cctx->ctx_had_return)
|
||||
if (!cctx->ctx_had_return && !cctx->ctx_had_throw)
|
||||
// the previous if block didn't end in a "return" or a "throw"
|
||||
// statement.
|
||||
ifscope->is_had_return = FALSE;
|
||||
|
||||
if (scope->se_u.se_if.is_if_label >= 0)
|
||||
|
Reference in New Issue
Block a user