Subject: bug#54195: 27.1; electric-pair-mode assertion failure in HTML+JS mode

From: Jeff Chase <[email-masked]>
Date: Sun, 27 Feb 2022 22:29:58 -0500

1) open a new file named 'test.html'
2) enable electric-pair-mode
3) Add

    <script>

    </script>

4) When mark is between script tags should be in HTML+JS mode
5) Enter `foo()` on the line between script tags

The closing paren should overwrite the auto closing paren but instead
a new one is added and the minibuffer shows an error:

    Assertion failed: (>= (cadr sgml--syntax-propertize-ppss) 0)

This does not happen under the other major modes I tried nor in HTML+
mode outside of the script tags.

In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu)
 of 2021-03-27, modified by Debian built on x86-conova-01
System Description: Debian GNU/Linux 11 (bullseye)

Recent messages:
next-line: End of buffer
(New file)
Type C-x 1 to delete the help window, C-M-v to scroll help.
Saving file /tmp/test...
Wrote /tmp/test
kill-line: End of buffer
Auto-saving...done
cl--assertion-failed: Assertion failed: (>= (cadr
sgml--syntax-propertize-ppss) 0)
Auto-saving...

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --build
 x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
 --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils --with-x=no
 --without-gsettings 'CFLAGS=-g -O2
 -ffile-prefix-map=/build/emacs-LlFm6W/emacs-27.1+1=.
-fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
SOUND GPM DBUS NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 ZLIB XIM
MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2 GMP

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: HTML+JS

Minor modes in effect:
  electric-pair-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-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 dired dired-loaddefs rfc822
mml mml-sec epa derived epg epg-config mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail cl-extra
help-fns radix-tree help-mode cus-start cus-load elec-pair mhtml-mode
css-mode smie eww mm-url gnus nnheader gnus-util rmail rmail-loaddefs
rfc2047 rfc2045 ietf-drums time-date mail-utils wid-edit mm-util
mail-prsvr thingatpt url-queue url url-proxy url-privacy url-expand
url-methods url-history mailcap shr text-property-search url-cookie
url-domsuf url-util puny image svg xml format-spec color js imenu
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs sgml-mode dom term/xterm xterm regexp-opt finder-inf
info tool-bar package easymenu browse-url url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch timer select mouse jit-lock font-lock syntax
facemenu font-core term/tty-colors frame minibuffer 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
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 threads dbusbind
inotify lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 281157 11962)
 (symbols 48 20226 1)
 (strings 32 93300 2645)
 (string-bytes 1 2493314)
 (vectors 16 24683)
 (vector-slots 8 311705 10980)
 (floats 8 233 302)
 (intervals 56 570 0)
 (buffers 1000 17))