To: vim_dev@googlegroups.com Subject: Patch 8.2.4534 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4534 Problem: Vim9: "is" operator with empty string and null returns true. Solution: Consider empty string and null to be different for "is". Files: src/typval.c, src/vim9execute.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.4533/src/typval.c 2022-03-09 11:56:17.873358764 +0000 --- src/typval.c 2022-03-10 12:20:44.214561935 +0000 *************** *** 1583,1591 **** i = ic ? MB_STRICMP(s1, s2) : STRCMP(s1, s2); switch (type) { ! case EXPR_IS: case EXPR_EQUAL: val = (i == 0); break; ! case EXPR_ISNOT: case EXPR_NEQUAL: val = (i != 0); break; case EXPR_GREATER: val = (i > 0); break; case EXPR_GEQUAL: val = (i >= 0); break; --- 1583,1605 ---- i = ic ? MB_STRICMP(s1, s2) : STRCMP(s1, s2); switch (type) { ! case EXPR_IS: if (in_vim9script()) ! { ! // Really check it is the same string, not just ! // the same value. ! val = tv1->vval.v_string == tv2->vval.v_string; ! break; ! } ! // FALLTHROUGH case EXPR_EQUAL: val = (i == 0); break; ! case EXPR_ISNOT: if (in_vim9script()) ! { ! // Really check it is not the same string, not ! // just a different value. ! val = tv1->vval.v_string != tv2->vval.v_string; ! break; ! } ! // FALLTHROUGH case EXPR_NEQUAL: val = (i != 0); break; case EXPR_GREATER: val = (i > 0); break; case EXPR_GEQUAL: val = (i >= 0); break; *** ../vim-8.2.4533/src/vim9execute.c 2022-03-08 13:18:10.809020782 +0000 --- src/vim9execute.c 2022-03-10 12:13:54.991381915 +0000 *************** *** 3313,3321 **** break; default: tv->v_type = VAR_STRING; ! tv->vval.v_string = vim_strsave( ! iptr->isn_arg.string == NULL ! ? (char_u *)"" : iptr->isn_arg.string); } break; --- 3313,3320 ---- break; default: tv->v_type = VAR_STRING; ! tv->vval.v_string = iptr->isn_arg.string == NULL ! ? NULL : vim_strsave(iptr->isn_arg.string); } break; *** ../vim-8.2.4533/src/testdir/test_vim9_expr.vim 2022-03-08 19:43:51.688198945 +0000 --- src/testdir/test_vim9_expr.vim 2022-03-10 12:01:30.956558962 +0000 *************** *** 801,806 **** --- 801,813 ---- assert_false(null_string != null) assert_false(v:null != test_null_string()) assert_false(null != null_string) + + assert_true(null_string is test_null_string()) + assert_false(null_string is '') + assert_false('' is null_string) + assert_false(null_string isnot test_null_string()) + assert_true(null_string isnot '') + assert_true('' isnot null_string) END v9.CheckDefAndScriptSuccess(lines) unlet g:null_dict *** ../vim-8.2.4533/src/version.c 2022-03-09 19:46:43.161299056 +0000 --- src/version.c 2022-03-10 12:14:21.147331519 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4534, /**/ -- hundred-and-one symptoms of being an internet addict: 219. Your spouse has his or her lawyer deliver the divorce papers... via e-mail. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///