]> granicus.if.org Git - vim/commitdiff
patch 8.2.0539: comparing two NULL list fails v8.2.0539
authorBram Moolenaar <Bram@vim.org>
Thu, 9 Apr 2020 19:33:22 +0000 (21:33 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 9 Apr 2020 19:33:22 +0000 (21:33 +0200)
Problem:    Comparing two NULL list fails.
Solution:   Change the order of comparing two lists.

src/list.c
src/testdir/test_assert.vim
src/version.c

index 9fe53841434710a786a959a04fdca924d3f10ead..451e58591095b67b6b8dcb2af355b6467cad663c 100644 (file)
@@ -368,12 +368,15 @@ list_equal(
 {
     listitem_T *item1, *item2;
 
-    if (l1 == NULL || l2 == NULL)
-       return FALSE;
     if (l1 == l2)
        return TRUE;
     if (list_len(l1) != list_len(l2))
        return FALSE;
+    if (list_len(l1) == 0)
+       // empty and NULL list are considered equal
+       return TRUE;
+    if (l1 == NULL || l2 == NULL)
+       return FALSE;
 
     range_list_materialize(l1);
     range_list_materialize(l2);
index 1b1f9e5151149ac340df43e21a69a17123ec3083..762f12ff536dac801186b17d8f6d79f8a45980a9 100644 (file)
@@ -36,6 +36,9 @@ func Test_assert_equal()
   call assert_equal(0, assert_equal(4, n))
   let l = [1, 2, 3]
   call assert_equal(0, assert_equal([1, 2, 3], l))
+  call assert_equal(test_null_list(), test_null_list())
+  call assert_equal(test_null_list(), [])
+  call assert_equal([], test_null_list())
 
   let s = 'foo'
   call assert_equal(1, assert_equal('bar', s))
index 0c147cce9801ba2939704d382cad7f718d0530d6..2bba57d7d992118826d9caf0e55df9493cf2900e 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    539,
 /**/
     538,
 /**/