To: vim_dev@googlegroups.com Subject: Patch 8.2.1412 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1412 Problem: Vim: not operator does not result in boolean. Solution: Make type depend on operator. (issue 6678) Fix using "false" and "true" in Vim9 script. Files: src/eval.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1411/src/eval.c 2020-08-08 15:45:58.233358630 +0200 --- src/eval.c 2020-08-09 22:16:19.545582742 +0200 *************** *** 3222,3233 **** --- 3222,3235 ---- { rettv->v_type = VAR_BOOL; rettv->vval.v_number = VVAL_TRUE; + ret = OK; } else if (len == 5 && in_vim9script() && STRNCMP(s, "false", 4) == 0) { rettv->v_type = VAR_BOOL; rettv->vval.v_number = VVAL_FALSE; + ret = OK; } else ret = eval_variable(s, len, rettv, NULL, TRUE, FALSE); *************** *** 3271,3276 **** --- 3273,3279 ---- int ret = OK; int error = FALSE; varnumber_T val = 0; + vartype_T type = rettv->v_type; #ifdef FEAT_FLOAT float_T f = 0.0; *************** *** 3301,3307 **** --- 3304,3313 ---- f = !f; else #endif + { val = !val; + type = VAR_BOOL; + } } else if (*end_leader == '-') { *************** *** 3310,3316 **** --- 3316,3325 ---- f = -f; else #endif + { val = -val; + type = VAR_NUMBER; + } } } #ifdef FEAT_FLOAT *************** *** 3323,3329 **** #endif { clear_tv(rettv); ! rettv->v_type = VAR_NUMBER; rettv->vval.v_number = val; } } --- 3332,3341 ---- #endif { clear_tv(rettv); ! if (in_vim9script()) ! rettv->v_type = type; ! else ! rettv->v_type = VAR_NUMBER; rettv->vval.v_number = val; } } *** ../vim-8.2.1411/src/testdir/test_vim9_expr.vim 2020-08-09 19:02:46.281077049 +0200 --- src/testdir/test_vim9_expr.vim 2020-08-09 22:12:17.793618513 +0200 *************** *** 1313,1318 **** --- 1313,1328 ---- assert_equal(g:special_false, false) assert_equal(g:special_true, v:true) assert_equal(g:special_false, v:false) + + assert_equal(true, !false) + assert_equal(false, !true) + assert_equal(true, !0) + assert_equal(false, !1) + assert_equal(false, !!false) + assert_equal(true, !!true) + assert_equal(false, !!0) + assert_equal(true, !!1) + assert_equal(g:special_null, v:null) assert_equal(g:special_none, v:none) *************** *** 1332,1337 **** --- 1342,1355 ---- assert_equal(true, t) assert_equal(v:false, false) assert_equal(false, f) + assert_equal(true, !false) + assert_equal(false, !true) + assert_equal(true, !0) + assert_equal(false, !1) + assert_equal(false, !!false) + assert_equal(true, !!true) + assert_equal(false, !!0) + assert_equal(true, !!1) END CheckScriptSuccess(lines) enddef *** ../vim-8.2.1411/src/version.c 2020-08-09 21:45:48.716655399 +0200 --- src/version.c 2020-08-09 22:17:19.005541146 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1412, /**/ -- "The question of whether computers can think is just like the question of whether submarines can swim." -- Edsger W. Dijkstra /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///