# HG changeset patch # User Bram Moolenaar # Date 1586461503 -7200 # Node ID c0eb073378e797a17d924d205b41f8b58084e1e2 # Parent 98fb36b068e4f57ed7b3ce120e9a4f19f9b6924f patch 8.2.0539: comparing two NULL list fails Commit: https://github.com/vim/vim/commit/7b293c730b07d1586688e622b8d9cbbb4a52379b Author: Bram Moolenaar Date: Thu Apr 9 21:33:22 2020 +0200 patch 8.2.0539: comparing two NULL list fails Problem: Comparing two NULL list fails. Solution: Change the order of comparing two lists. diff --git a/src/list.c b/src/list.c --- a/src/list.c +++ b/src/list.c @@ -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); diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim --- a/src/testdir/test_assert.vim +++ b/src/testdir/test_assert.vim @@ -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)) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 539, +/**/ 538, /**/ 537,