Hash table entry with key and value of :EMPTY is treated as an empty entry.
|Reported by:||rtoy||Owned by:||somebody|
(defvar *h* (make-hash-table)) (setf (gethash :empty *h*) :empty) (maphash #'(lambda (k v) (format t "~A -> ~A~%" k v)) *h*)
produces no output, but printing *h* indicates the hash table has one entry in it.
This is a bug in how the hash tables indicate an empty slot. The key-value vector uses a key and value of :EMPTY to indicate an empty slot.
A possible solution: The second slot in the key-value vector is the symbol :EMPTY, but is otherwise not used for anything. So, instead of putting :EMPTY there, we can put a gensym'ed symbol there instead, and initialize all the remaining slots of the kv vector to be this symbol. I don't think there's any impact on GC, because if the GC code needs the empty symbol, it uses kv_vector to get it. The Lisp code needs to change to initialize the kv-vector appropriately. maphash and with-hash-table-iterator need to use kv_vector instead of :EMPTY to determine if a slot is empty or not.
I think this should work.