patch 9.1.0197: Vim9: problem evaluating negated boolean logic Commit: https://github.com/vim/vim/commit/5d77364e4afe69b28f6d8b3493595c5c6fc056b8 Author: Yegappan Lakshmanan <yegap...@yahoo.com> Date: Fri Mar 22 19:37:29 2024 +0100
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 <yegap...@yahoo.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 6285ba124..7764b3791 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -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() diff --git a/src/version.c b/src/version.c index ad9f6e1df..2c1cd161c 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 197, /**/ 196, /**/ diff --git a/src/vim9expr.c b/src/vim9expr.c index ee9712bfd..9d67aead5 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -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]; -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/E1rnk7Y-00HNdA-4t%40256bit.org.