mirror of
https://github.com/vim/vim.git
synced 2025-10-24 08:54:47 -04:00
patch 9.1.0514: Vim9: issue with comparing objects recursively
Problem: Vim9: issue with comparing objects recursively
(Yinzuo Jiang)
Solution: only set recursive == TRUE, when called from tv_equal(), not
from typeval_compare_object(), refactor code into object_equal()
function (LemonBoy)
The recursive flag in tv_equal should be set only when the caller is
tv_equal, meaning that the comparison depth is > 1. The comparison
predicates for other object types are all following this rule, except
for the object one, and that may cause some weird issues like causing
the max depth limit not to be initialized in some cases.
closes: #15076
Signed-off-by: LemonBoy <thatlemon@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
549ecc8636
commit
7b29cc97d6
19
src/typval.c
19
src/typval.c
@@ -1742,14 +1742,6 @@ typval_compare_object(
|
||||
return OK;
|
||||
}
|
||||
|
||||
class_T *cl1 = tv1->vval.v_object->obj_class;
|
||||
class_T *cl2 = tv2->vval.v_object->obj_class;
|
||||
if (cl1 != cl2 || cl1 == NULL || cl2 == NULL)
|
||||
{
|
||||
*res = !res_match;
|
||||
return OK;
|
||||
}
|
||||
|
||||
object_T *obj1 = tv1->vval.v_object;
|
||||
object_T *obj2 = tv2->vval.v_object;
|
||||
if (type == EXPR_IS || type == EXPR_ISNOT)
|
||||
@@ -1758,14 +1750,7 @@ typval_compare_object(
|
||||
return OK;
|
||||
}
|
||||
|
||||
for (int i = 0; i < cl1->class_obj_member_count; ++i)
|
||||
if (!tv_equal((typval_T *)(obj1 + 1) + i,
|
||||
(typval_T *)(obj2 + 1) + i, ic, TRUE))
|
||||
{
|
||||
*res = !res_match;
|
||||
return OK;
|
||||
}
|
||||
*res = res_match;
|
||||
*res = object_equal(obj1, obj2, ic, FALSE) ? res_match : !res_match;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -2115,7 +2100,7 @@ tv_equal(
|
||||
|
||||
case VAR_OBJECT:
|
||||
++recursive_cnt;
|
||||
(void)typval_compare_object(tv1, tv2, EXPR_EQUAL, ic, &r);
|
||||
r = object_equal(tv1->vval.v_object, tv2->vval.v_object, ic, TRUE);
|
||||
--recursive_cnt;
|
||||
return r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user