0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.1.0197: Vim9: problem evaluating negated boolean logic

Problem:  Vim9: problem evaluating negated boolean logic
          (lxhillwind)
Solution: Don't clear the first value on short circuit evaluation
          (Yegappan Lakshmanan)

fixes: #14265
closes: #14269

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yegappan Lakshmanan
2024-03-22 19:37:29 +01:00
committed by Christian Brabandt
parent 8e37daf620
commit 5d77364e4a
3 changed files with 30 additions and 1 deletions

View File

@@ -311,6 +311,33 @@ def Test_expr2()
assert_equal([1], g:vals)
END
v9.CheckDefAndScriptSuccess(lines)
# test the short-circuit operation
lines =<< trim END
assert_equal(true, true && true)
assert_equal(false, true && !true)
assert_equal(false, !true && true)
assert_equal(false, !true && !true)
assert_equal(true, true || true)
assert_equal(true, true || !true)
assert_equal(true, !true || true)
assert_equal(false, !true || !true)
assert_equal(false, false && false)
assert_equal(false, false && !false)
assert_equal(false, !false && false)
assert_equal(true, !false && !false)
assert_equal(false, false || false)
assert_equal(true, false || !false)
assert_equal(true, !false || false)
assert_equal(true, !false || !false)
assert_equal(false, !true && !true && !true)
assert_equal(true, !false || !false || !false)
END
v9.CheckDefAndScriptSuccess(lines)
enddef
def Test_expr2_vimscript()

View File

@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
197,
/**/
196,
/**/

View File

@@ -2779,7 +2779,7 @@ compile_expr9(
if (compile_subscript(arg, cctx, start_leader, &end_leader,
ppconst) == FAIL)
return FAIL;
if (ppconst->pp_used > 0)
if ((ppconst->pp_used > 0) && (cctx->ctx_skip != SKIP_YES))
{
// apply the '!', '-' and '+' before the constant
rettv = &ppconst->pp_tv[ppconst->pp_used - 1];