Subject: bug#54990: Byte compiler bug

From: Mattias Engdegård <[email-masked]>
Date: Sun, 17 Apr 2022 16:32:53 +0200

This is related to symbol positioning so Alan should be well-placed to debug it. (The symbol names are irrelevant.)

It's `compile-defun` that is broken; the constant vector of the resulting bytecode contains symbols with position as hash table keys for a switch operation. Compare the bytecode object with that from `byte-compile` which works correctly:

(defun tata (x)
  (cond
   ((eq x 'a) 'toto)
   ((eq x 'b) 'titi)))

(byte-compile 'tata)
=>
#[257 "..." [#s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (a 6 b 8)) toto titi nil] 3 "..."]

;; if using `compile-defun` on `tata`:
(symbol-function 'tata)
#[257 "..." [#s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (#<symbol a at 293> 6 #<symbol b at 314> 8)) toto titi nil] 3 "..."]