Subject: 26.1; Strange behavior of `cond'
From: Ikumi Keita <[email-masked]>
To: [email-masked]
Date: Tue, 05 Jun 2018 15:26:02 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

The special form `cond' does not return expected value under a specific
condition.

[How to reproduce]
1. Save the following file as /tmp/test.el
---- test.el ---------------------------------------------------------
(defun xyz (arg)
  "dummy"
;    (cond ((eq arg nil) ; OK
;    (cond ((eq arg 'abc) ; OK
;    (cond ((eq arg 'def) ; OK
    (cond ((eq arg 'default) ; NG
;    (cond ((eq arg 'default1) ; OK
	   "A")
	  (t
	   "B")))

(byte-compile 'xyz)

(insert (xyz t)) ; should "B", but "A" in actual
----------------------------------------------------------------------
2. emacs-26.1 -Q -l /tmp/test.el
3. Expected result:
   "B" is inserted in *scratch*
   Actual result:
   "A" is inserted in *scratch*

[Some notes related to this issue]
a. As the comments written in the above code, only the symbol `default'
   triggers this behavior.
b. Emacs 25.3 doesn't have this problem.
c. If `xyz' is not byte compiled, `cond' works as expected.
d. It seems that the following entry in NEWS is related:
** Certain cond/pcase/cl-case forms are now compiled using a faster jump
table implementation.  This uses a new bytecode op 'switch', which
isn't compatible with previous Emacs versions.  This functionality can
be disabled by setting 'byte-compile-cond-use-jump-table' to nil.
   If I replace the line `(byte-compile 'xyz)' with
(let ((byte-compile-cond-use-jump-table nil))
  (byte-compile 'xyz))
   in the above example, `cond' works as expected.

In GNU Emacs 26.1 (build 1, x86_64-unknown-freebsd11.1, GTK+ Version 3.22.29)
 of 2018-05-30 built on freebsd.vmware
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
Recent messages:
Saving file /home/keita/Mail/drafts/1...
Wrote /home/keita/Mail/drafts/1
next-line: End of buffer [2 times]
Saving file /home/keita/Mail/drafts/1...
Wrote /home/keita/Mail/drafts/1
next-line: End of buffer [4 times]
Sending...backgrounded
Scanning +drafts...done
No messages in +drafts, range (all)
Quit [2 times]
user-error: No cross-references in this node
Configured using:
 'configure --with-canna --with-canna-includes=/usr/local/canna/include
--with-canna-libraries=/usr/local/canna/lib --mandir=/usr/local/man
--without-xim --with-sound=yes --with-file-notification=yes
--disable-largefile --without-pop CFLAGS=-O3'

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS NOTIFY ACL GNUTLS
LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LCMS2

Important settings:
  value of $EMACSLOADPATH: /home/keita/elisp:
  value of $LANG: ja_JP.eucJP
  value of $XMODIFIERS: @im=fcitx
  locale-coding-system: japanese-iso-8bit-unix

Major mode: Info

Minor modes in effect:
  TeX-PDF-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
~/elisp/preview hides /usr/local/share/emacs/site-lisp/auctex/preview
~/elisp/tex-buf hides /usr/local/share/emacs/site-lisp/auctex/tex-buf
~/elisp/tex hides /usr/local/share/emacs/site-lisp/auctex/tex
~/elisp/reftex-parse hides /usr/local/share/emacs/26.1/lisp/textmodes/reftex-parse

Features:
(shadow emacsbug latexenc supercite regi mh-identity mh-letter mh-comp
sendmail qp info view mh-alias multi-prompt smiley mm-archive mail-extr
mh-mime mh-gnus mh-show goto-addr gnus-cite gnus-art mm-uu mml2015
mm-view mml-smime smime dig mh-inc hl-line mh-tool-bar mh-seq mh-xface
mh-utils mh-folder which-func imenu mh-scan mh-e mh-compat mh-buffers
mh-loaddefs preview prv-emacs reftex-dcr reftex-auc reftex
reftex-loaddefs reftex-vars tex-fold tex-bar tex-buf toolbar-x
font-latex latex edmacro kmacro latex-flymake flymake-proc flymake
warnings thingatpt tex-ispell tex-style tex dbus crm tex-mode compile
shell misearch multi-isearch vc-dispatcher vc-hg org-archive skeleton
org-rmail org-mhe org-irc org-info org-gnus nnir gnus-sum gnus-group
gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source utf7 netrc
nnoo gnus-spec gnus-int gnus-range message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mailabbrev gmm-utils mailheader gnus-win gnus
nnheader gnus-util rmail rmail-loaddefs mail-utils wid-edit org-docview
doc-view image-mode dired dired-loaddefs org-bibtex bibtex org-bbdb
org-w3m org-element avl-tree generator org org-macro org-footnote
org-pcomplete pcomplete org-list org-faces org-entities noutline outline
easy-mmode org-version ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob
ob-table ob-keys ob-exp ob-comint comint ansi-color ring ob-core ob-eval
org-compat org-macs org-loaddefs format-spec find-func cal-menu calendar
cal-loaddefs jka-compr cl-extra help-mode parse-time ucs-normalize json
map epa derived epg epg-config url-http tls gnutls url-auth mail-parse
rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm rmc
puny seq twittering-mode easymenu advice url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
url-parse auth-source cl-seq eieio byte-opt bytecomp byte-compile cconv
eieio-core cl-macs gv eieio-loaddefs cl-loaddefs cl-lib password-cache
url-vars mailcap xml elec-pair w3m-load preview-latex auto-loads
tex-site canna-im time-date mule-util japan-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote dbusbind kqueue lcms2 dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 585780 62716)
 (symbols 48 43330 1)
 (miscs 40 1448 1041)
 (strings 32 118129 14954)
 (string-bytes 1 4152041)
 (vectors 16 71953)
 (vector-slots 8 1968759 71038)
 (floats 8 346 479)
 (intervals 56 6509 2189)
 (buffers 992 42))