Subject: bug#25941: 26.0.50; Different code behavior between using the auto-compiled and evaled versions

From: Vibhav Pant <[email-masked]>
Date: Thu, 9 Mar 2017 23:53:29 +0530

On Thu, Mar 9, 2017 at 10:01 PM, Kaushal Modi <[email-masked]> wrote:
> This issue seems to be related to the switch bytecode change.

`cond' returns the value of the met condition when the clause doesn't
have a body. That's what seems to be happening when (eq res 'exit).
The result should be t instead of nil. A similar example like:
(defun test (v)
  (cond ((eq v 1) 'one)
((eq v 2))
(t 'none)))
Also displays different results with (test 2) when byte compiled. I've
added a patch to bytecomp.el which tries to fix this, could you apply
it and see whether the issue still exists?

Thanks,
Vibhav

-- 
Vibhav Pant
[email-masked]
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 25513bd024..068988813a 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -4128,7 +4128,9 @@ byte-compile-cond-jump-table
           ;; depth/tag conflicts or violating asserts down the road.
           ;; To make sure `byte-compile-body' itself doesn't violate this,
           ;; we use `cl-assert'.
-          (byte-compile-body body byte-compile--for-effect)
+          (if (null body)
+              (byte-compile-body '(t) byte-compile--for-effect)
+            (byte-compile-body body byte-compile--for-effect))
           (cl-assert (or (= byte-compile-depth init-depth)
                          (= byte-compile-depth (1+ init-depth))))
           (byte-compile-goto 'byte-goto donetag)