summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-06-28 06:55:12 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-06-28 06:55:12 -0700
commit59478a2944d8f9a06a8481bd2f746ffd7dd764c7 (patch)
tree0f710f8be8ab9cb1d057c4d86825aed161285b22 /lib.c
parent60708150c2efd57f34962b336d9e63684a00aeca (diff)
downloadtxr-59478a2944d8f9a06a8481bd2f746ffd7dd764c7.tar.gz
txr-59478a2944d8f9a06a8481bd2f746ffd7dd764c7.tar.bz2
txr-59478a2944d8f9a06a8481bd2f746ffd7dd764c7.zip
equal: bug: broken equality substitution.
* lib.c (equal): Several cases which react to the type of the left argument have a default path which wrongly short-circuits to an early return. All these cases must break through to the logic at the end of the function which tests the right side for a possible equality substitution. * tests/012/struct.tl: One breaking test cases added. equal was found to return nil for two structures that have equal lists as their equality substitute.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib.c b/lib.c
index b5eb4d1e..03e6efb8 100644
--- a/lib.c
+++ b/lib.c
@@ -4231,7 +4231,7 @@ val equal(val left, val right)
default:
break;
}
- return nil;
+ break;
case LCONS:
switch (type(right)) {
case CONS:
@@ -4331,7 +4331,7 @@ val equal(val left, val right)
default:
return nil;
}
- return nil;
+ break;
case BGNUM:
if (type(right) == BGNUM) {
if (mp_cmp(mp(left), mp(right)) == MP_EQ)
@@ -4381,7 +4381,7 @@ val equal(val left, val right)
if (type(right) == COBJ && left->co.ops == right->co.ops)
return left->co.ops->equal(left, right);
- return nil;
+ break;
case CPTR:
if (type(right) == CPTR && left->co.ops == right->co.ops)
return left->co.ops->equal(left, right);