Subject: bug#39805: 28.0.50; scan-sexps (scan_lists) incorrectly parsing circular list

From: Noam Postavsky <[email-masked]>
Date: Wed, 26 Feb 2020 20:38:12 -0500

# seems to be long standing
found 39805 25.3
tags 39805 + confirmed
quit

No Wayman <[email-masked]> writes:

> While developing a package that utilizes circular lists, I ran 
> into a bug when trying to describe-variable
> a variable that contains circular lists. I've hewed it down to the 
> following:
>
> ** Minimal Reproducible Case
>
> #+begin_src emacs-lisp :results raw h replace
> (condition-case-unless-debug err
>     (with-temp-buffer
>       (insert "(#9=() :key val)")
>       (pp-buffer)
>       nil)

It doesn't fail if the buffer is changed to emacs-lisp-mode before the
pp-buffer call.  I guess scan-sexps doesn't handle the #N= correctly
unless the syntax-table has been set for emacs-lisp.  I note that
pp-to-string does some setup on its temp buffer, so maybe
describe-variable needs to do that too.

For the record, to reproduce the error from describe-variable, a
slightly less minimal example is needed (because the value must be more
than 68 characters long to trigger pretty printing)

    (setq vv '(#1=(a b) :key val #1# :key val :key val :key val :key val))
    (describe-variable 'vv)