diff src/typval.c @ 28019:53e2bf6032e5 v8.2.4534

patch 8.2.4534: Vim9: "is" operator with empty string and null returns true Commit: https://github.com/vim/vim/commit/f8691004b069f67becd657a02100d7521d1255a9 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 10 12:20:53 2022 +0000 patch 8.2.4534: Vim9: "is" operator with empty string and null returns true Problem: Vim9: "is" operator with empty string and null returns true. Solution: Consider empty string and null to be different for "is".
author Bram Moolenaar <Bram@vim.org>
date Thu, 10 Mar 2022 13:30:12 +0100
parents d10d5cc8e657
children 1615d305c71d
line wrap: on
line diff
--- a/src/typval.c
+++ b/src/typval.c
@@ -1583,9 +1583,23 @@ typval_compare_string(
 	i = ic ? MB_STRICMP(s1, s2) : STRCMP(s1, s2);
     switch (type)
     {
-	case EXPR_IS:
+	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:
+	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;