From 94bf3d030cfad17150a548377ebd0cdedd8d9080 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Sun, 17 Oct 2010 00:22:23 +0200 Subject: [PATCH] Fixed bug where objects without order relation were considered equal. This could cause multisets with objects to not insert new objects even when they weren't equal according to `==. Bug introduced in aea87ea. --- src/array.c | 2 +- src/testsuite.in | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/array.c b/src/array.c index e2aba3abc6..f6ffdf9057 100644 --- a/src/array.c +++ b/src/array.c @@ -1056,7 +1056,7 @@ static int obj_or_func_cmp (const struct svalue *a, const struct svalue *b) return a->u.object->prog < b->u.object->prog ? -1 : 1; } - return res == 2 ? 0 : res; + return res == 2 ? -1 : res; } int set_svalue_cmpfun(const struct svalue *a, const struct svalue *b) diff --git a/src/testsuite.in b/src/testsuite.in index f6870284a4..3356cd526a 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -5435,6 +5435,18 @@ test_any_equal([[ return sort ((array) (m - (<>))); ]], ({"2", "Stone"})) +test_any([[ + class X (int i) { + int `< (mixed o) {return 0;} + int `== (mixed o) {return 0;} + }; + multiset m = (<X(2)>); + m[X(4)] = 1; + m[X(1)] = 1; + m[X(3)] = 1; + return sizeof (m); +]], 4) + // mapping tests test_any([[mapping m=([]);int e; -- GitLab