summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2023-09-04 12:51:24 +0000
committerAlan Mackenzie <acm@muc.de>2023-09-04 12:51:24 +0000
commitafcb6d0bc7abcdbca6b18d020deeff24d1ad197f (patch)
tree1561281df0284ced50d19005770c00023e7a617e /src
parent55a0f0e047034b3a458b6fdbe245f33b83fd88b0 (diff)
Correct the handling of symbols with position in equal
* src/fns.c (internal_equal): Only regard symbols with position as their symbols when symbols-with-pos-enabled is non-nil. * doc/lispref/symbols.texi (Symbols with Position): Expand the description of symbols with position, in particular the way they work with eq and equal. * doc/lispref/objects.texi (Equality Predicates): Describe how eq and equal handle symbols with position. * test/src/fns-tests.el (fns-tests-equal-symbols-with-position): New tests for symbols with position.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/fns.c b/src/fns.c
index ae9969a5432..bd1d63a58c4 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2774,10 +2774,13 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
/* A symbol with position compares the contained symbol, and is
`equal' to the corresponding ordinary symbol. */
- if (SYMBOL_WITH_POS_P (o1))
- o1 = SYMBOL_WITH_POS_SYM (o1);
- if (SYMBOL_WITH_POS_P (o2))
- o2 = SYMBOL_WITH_POS_SYM (o2);
+ if (symbols_with_pos_enabled)
+ {
+ if (SYMBOL_WITH_POS_P (o1))
+ o1 = SYMBOL_WITH_POS_SYM (o1);
+ if (SYMBOL_WITH_POS_P (o2))
+ o2 = SYMBOL_WITH_POS_SYM (o2);
+ }
if (BASE_EQ (o1, o2))
return true;
@@ -2825,8 +2828,8 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
if (ASIZE (o2) != size)
return false;
- /* Compare bignums, overlays, markers, and boolvectors
- specially, by comparing their values. */
+ /* Compare bignums, overlays, markers, boolvectors, and
+ symbols with position specially, by comparing their values. */
if (BIGNUMP (o1))
return mpz_cmp (*xbignum_val (o1), *xbignum_val (o2)) == 0;
if (OVERLAYP (o1))
@@ -2858,6 +2861,11 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
if (TS_NODEP (o1))
return treesit_node_eq (o1, o2);
#endif
+ if (SYMBOL_WITH_POS_P(o1)) /* symbols_with_pos_enabled is false. */
+ return (BASE_EQ (XSYMBOL_WITH_POS (o1)->sym,
+ XSYMBOL_WITH_POS (o2)->sym)
+ && BASE_EQ (XSYMBOL_WITH_POS (o1)->pos,
+ XSYMBOL_WITH_POS (o2)->pos));
/* Aside from them, only true vectors, char-tables, compiled
functions, and fonts (font-spec, font-entity, font-object)