Subject: bug#18764: 24.4; electric-indent in *scratch* signals an error

From: Noam Postavsky <[email-masked]>
Date: Thu, 14 Jun 2018 22:34:35 -0400

tags 18764 + confirmed
found 18764 26.1
quit

Eli Zaretskii <[email-masked]> writes:

> In "emacs -Q":
>
> 1) Insert the following long sequence of left parens followed by a somewhat
> shorter sequence of right parens:

Specifically, the sequence of left parens must be more than 100, to hit
this limit:

static void
scan_sexps_forward(...)
{...
  struct level levelstart[100];
  struct level *curlevel = levelstart;
  struct level *endlevel = levelstart + 100;
  ...
        case Sopen:
          ...
          if (++curlevel == endlevel)
            curlevel--; /* error ("Nesting too deep for parser"); */

and a sequence of 100 close parens so that the curlevel stack will be
completely popped:

        case Sclose:
          ...
          if (curlevel != levelstart)
            curlevel--;

In this case parse-partial-sexp will have the right depth, but
incorrectly have nil for element 2 "character address of start of last
complete sexp terminated."

Not sure exactly what to do about this though.  Maybe parse-partial-sexp
should (optionally?) signal an error when the curlevel stack overflows?