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.
This commit is contained in:
Alan Mackenzie
2023-09-04 12:51:24 +00:00
parent 55a0f0e047
commit afcb6d0bc7
4 changed files with 72 additions and 19 deletions

View File

@@ -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))