commit 2cb0860117623368bc53e4d578695136ce6912e0
parent 47ad4c8701b4233aa302c1c21ff08a5f223596c7
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sun, 13 Nov 2022 07:17:57 +0800
vim-patch:8.2.4675: no error for missing expression after :elseif
Problem: No error for missing expression after :elseif. (Ernie Rael)
Solution: Check for missing expression. (closes vim/vim#10068)
https://github.com/vim/vim/commit/fa010cdfb115fd2f6bae7ea6f6e63be906b5e347
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
@@ -899,7 +899,13 @@ void ex_else(exarg_T *eap)
if (eap->cmdidx == CMD_elseif) {
bool error;
- result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
+ // When skipping we ignore most errors, but a missing expression is
+ // wrong, perhaps it should have been "else".
+ if (skip && ends_excmd(*eap->arg)) {
+ semsg(_(e_invexpr2), eap->arg);
+ } else {
+ result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
+ }
// When throwing error exceptions, we want to throw always the first
// of several errors in a row. This is what actually happens when