From afcb6d0bc7abcdbca6b18d020deeff24d1ad197f Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Mon, 4 Sep 2023 12:51:24 +0000 Subject: 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. --- test/src/fns-tests.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/src') diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index 79ae4393f40..9c09e4f0c33 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el @@ -98,6 +98,26 @@ (should-not (equal-including-properties #("a" 0 1 (k "v")) #("b" 0 1 (k "v"))))) +(ert-deftest fns-tests-equal-symbols-with-position () + "Test `eq' and `equal' on symbols with position." + (let ((foo1 (position-symbol 'foo 42)) + (foo2 (position-symbol 'foo 666)) + (foo3 (position-symbol 'foo 42))) + (let (symbols-with-pos-enabled) + (should (eq foo1 foo1)) + (should (equal foo1 foo1)) + (should-not (eq foo1 foo2)) + (should-not (equal foo1 foo2)) + (should-not (eq foo1 foo3)) + (should (equal foo1 foo3))) + (let ((symbols-with-pos-enabled t)) + (should (eq foo1 foo1)) + (should (equal foo1 foo1)) + (should (eq foo1 foo2)) + (should (equal foo1 foo2)) + (should (eq foo1 foo3)) + (should (equal foo1 foo3))))) + (ert-deftest fns-tests-reverse () (should-error (reverse)) (should-error (reverse 1)) -- cgit v1.2.1