1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Don't allow the eq and unbind byte-ops to commute (bug#65017)

* lisp/emacs-lisp/byte-opt.el (byte-after-unwind-ops):
Cease sinking `eq` past `unwind`, because that optimised away the
let-binding in

  (let ((symbols-with-pos-enabled nil))
    (eq x y))

and `eq` is currently sensitive to `symbols-with-pos-enabled`.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp--eq-symbols-with-pos-enabled): New test.
This commit is contained in:
Mattias Engdegård 2023-08-04 11:08:57 +02:00
parent c75c799719
commit 44d7fd3805
2 changed files with 40 additions and 1 deletions

View file

@ -2141,7 +2141,7 @@ See Info node `(elisp) Integer Basics'."
'(byte-constant byte-dup byte-stack-ref byte-stack-set byte-discard
byte-discardN byte-discardN-preserve-tos
byte-symbolp byte-consp byte-stringp byte-listp byte-numberp byte-integerp
byte-eq byte-not
byte-not
byte-cons byte-list1 byte-list2 byte-list3 byte-list4 byte-listN
byte-interactive-p)
;; How about other side-effect-free-ops? Is it safe to move an
@ -2149,6 +2149,11 @@ See Info node `(elisp) Integer Basics'."
;; No, it is not, because the unwind-protect forms can alter
;; the inside of the object to which nth would apply.
;; For the same reason, byte-equal was deleted from this list.
;;
;; In particular, `byte-eq' isn't here despite `eq' being nominally
;; pure because it is currently affected by `symbols-with-pos-enabled'
;; and so cannot be sunk past an unwind op that might end a binding of
;; that variable. Yes, this is unsatisfactory.
"Byte-codes that can be moved past an unbind.")
(defconst byte-compile-side-effect-and-error-free-ops