Subject: 26.1; REGRESSION: `indent-pp-sexp' Wrong type argument: consp, nil

From: Drew Adams <[email-masked]>
Date: Sun, 3 Mar 2019 09:29:32 -0800 (PST)

1. emacs -Q

2. C-x C-f foo.el

3. Enter this text. Be sure to hit RET after the final right paren, so there is a newline char at the end.

(defun foo ()
  (unless t 42)))

4. Put point just before the first left paren, then use `C-M-q'.

This error is raised:

Wrong type argument: consp, nil

If you turn on `debug-on-error' this is what you get:

Debugger entered--Lisp error: (wrong-type-argument consp nil)
  lisp-indent-calc-next(#s(lisp-indent-state :stack (2 nil) :ppss (1 1 12 nil nil nil 0 nil nil (1) nil) :ppss-point 14))
  indent-sexp()
  indent-pp-sexp(nil)
  funcall-interactively(indent-pp-sexp nil)
  call-interactively(indent-pp-sexp nil nil)
  command-execute(indent-pp-sexp)

I see the same regression in Emacs 27, this build (the latest I have):

In GNU Emacs 27.0.50 (build 3, x86_64-w64-mingw32)
 of 2018-03-21 built on CIRROCUMULUS
Repository revision: e70d0c9e66d7a8609450b2889869d16aeb0363b5
Windowing system distributor 'Microsoft Corp.', version 10.0.17134
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
throw-clone-fr-2.el has auto save data; consider M-x recover-this-file
indent-sexp: Wrong type argument: consp, nil
indent-sexp: Wrong type argument: consp, nil
Configured using:
 'configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install -C 'CFLAGS=-O2 -static -g3''

I do not see this bug in Emacs 25.3.1.

In GNU Emacs 26.1 (build 1, x86_64-w64-mingw32)
 of 2018-05-30 built on CIRROCUMULUS
Repository revision: 07f8f9bc5a51f5aa94eb099f3e15fbe0c20ea1ea
Windowing system distributor 'Microsoft Corp.', version 10.0.17134
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
indent-sexp: Wrong type argument: consp, nil
Configured using:
 'configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS THREADS LCMS2

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Emacs-Lisp

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-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
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib format-spec rfc822 mml
easymenu mml-sec password-cache epa derived epg epg-config gnus-util
rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils dired dired-loaddefs elec-pair time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win
w32-vars term/common-win 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 w32notify w32 lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 98254 9195)
 (symbols 56 20427 1)
 (miscs 48 59 191)
 (strings 32 29927 1011)
 (string-bytes 1 764152)
 (vectors 16 13997)
 (vector-slots 8 487459 12958)
 (floats 8 55 315)
 (intervals 56 248 29)
 (buffers 992 14))