From: Iurie Marian <marian.iurie@gmail.com>
To: 73270@debbugs.gnu.org, acorallo@gnu.org
Subject: bug#73270: 31.0.50; comp.el comp--type-check-optim pass causes issues
Date: Sun, 15 Sep 2024 10:27:48 +0200 [thread overview]
Message-ID: <CAP+jDP5vJn1M9hXSCdoRxuT=4iFQiK0E8Pge=xry-s6TV8qLdg@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 6004 bytes --]
Dear Emacs maintainers,
I encountered an issue with latest Emacs' master branch. I am using a
package `pcre2el'
and I noticed a wrong behavior after updating Emacs. I tracked the change
which causes the
issue, and it seems it's the below commit:
#+begin_comment
a1775552cef5a8bc0ba13e802ecf343423a53364
Author: Andrea Corallo <akrl@sdf.org>
AuthorDate: Tue May 23 11:18:07 2023 +0200
Commit: Andrea Corallo <acorallo@gnu.org>
CommitDate: Thu Jul 11 16:26:49 2024 +0200
#+end_comment
probably the newly introduced `comp--type-check-optim' is causing the issue.
Issue description:
* `pcre2el''s rxt-adt->strings execution expectation
#+begin_comment
ELISP> (rxt-adt->strings (rxt-parse-pcre (rxt--add-flags "t([es]{2})" nil)))
("tss" "tse" "tes" "tee")
#+end_comment
* The error
#+begin_comment
ELISP> (rxt-adt->strings (rxt-parse-pcre (rxt--add-flags "t([es]{4})" nil)))
*** Eval error *** Wrong type argument: listp, #s(rxt-repeat 4 4
#s(rxt-char-set-union (115 101) nil nil nil) t)
#+end_comment
That's how the above function [[
https://github.com/joddie/pcre2el/blob/b4d846d80dddb313042131cf2b8fbf647567e000/pcre2el.el#L2984C1-L3004C46][rxt-adt->strings]]
looks like:
#+begin_src emacs-lisp
(defun rxt-adt->strings (re)
(cl-typecase re
(rxt-primitive
(list ""))
(rxt-string
(list (rxt-string-chars re)))
(rxt-seq
(rxt-seq-elts->strings (rxt-seq-elts re)))
(rxt-choice
(rxt-choice-elts->strings (rxt-choice-elts re)))
(rxt-submatch
(rxt-adt->strings (rxt-submatch-body re)))
(rxt-submatch-numbered
(rxt-adt->strings (rxt-submatch-numbered-body re)))
(rxt-repeat
(rxt-repeat->strings re))
(rxt-char-set-union
(rxt-char-set->strings re))
(t
(error "Can't generate productions of %s"
(rxt-syntax-tree-readable re)))))
#+end_src
The issue comes from
#+begin_comment
(cl-typecase re
#+end_comment
instead of matching below:
#+begin_comment
(rxt-submatch
(rxt-adt->strings (rxt-submatch-body re)))
#+end_comment
it wrongly matches:
#+begin_comment
(rxt-seq
(rxt-seq-elts->strings (rxt-seq-elts re)))
#+end_comment
and throws the error
#+begin_comment
ELISP> (rxt-adt->strings (rxt-parse-pcre (rxt--add-flags "t([es]{4})" nil)))
*** Eval error *** Wrong type argument: listp, #s(rxt-repeat 4 4
#s(rxt-char-set-union (115 101) nil nil nil) t)
#+end_comment
To quickly check this I've added some traces:
#+begin_src emacs-lisp
(defun rxt-adt->strings (re)
(message "type-of re: %S, re = %S" (type-of re) re)
(cl-typecase re
(rxt-primitive
(progn (message "match: rxt-primitive")
(list "")))
(rxt-string
(progn (message "match: rxt-string")
(list (rxt-string-chars re))))
(rxt-seq
(progn (message "match: rxt-seq")
(rxt-seq-elts->strings (rxt-seq-elts re))))
(rxt-choice
(progn (message "match: rxt-choice")
(rxt-choice-elts->strings (rxt-choice-elts re))))
(rxt-submatch
(progn (message "match: rxt-submatch")
(rxt-adt->strings (rxt-submatch-body re))))
(rxt-submatch-numbered
(progn (message "match: rxt-submatch-numbered")
(rxt-adt->strings (rxt-submatch-numbered-body re))))
(rxt-repeat
(progn (message "match: rxt-repeat")
(rxt-repeat->strings re)))
(rxt-char-set-union
(progn (message "match: rxt-char-set-union")
(rxt-char-set->strings re)))
(t
(error "Can't generate productions of %s"
(rxt-syntax-tree-readable re)))))
#+end_src
which produces below messages:
#+begin_comment
type-of re: rxt-seq, re = #s(rxt-seq (#s(rxt-string "t" nil)
#s(rxt-submatch #s(rxt-repeat 4 4 #s(rxt-char-set-union (115 101) nil nil
nil) t))))
match: rxt-seq
type-of re: rxt-string, re = #s(rxt-string "t" nil)
match: rxt-string
type-of re: rxt-submatch, re = #s(rxt-submatch #s(rxt-repeat 4 4
#s(rxt-char-set-union (115 101) nil nil nil) t))
match: rxt-seq
#+end_comment
By commenting line (`comp--type-check-optim') in `comp-passes' (see below),
it fixes locally the issue, which makes me think that this is the culprit.
#+begin_src emacs-lisp
(defconst comp-passes '(comp--spill-lap
comp--limplify
comp--fwprop
comp--call-optim
comp--ipa-pure
comp--add-cstrs
comp--fwprop
;; comp--type-check-optim
comp--tco
comp--fwprop
comp--remove-type-hints
comp--sanitizer
comp--compute-function-types
comp--final)
"Passes to be executed in order.")
#+end_src
Kind Regards,
Iurie
In GNU Emacs 31.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version
3.24.41, cairo version 1.18.0) of 2024-09-13 built on rrouwprlc0222
Repository revision: 7376623a244a91d1de5245645b4b3e8c9469d422
Repository branch: master
System Description: Ubuntu 24.04.1 LTS
Configured using:
'configure 'CFLAGS= -O3 -fallow-store-data-races
-fno-semantic-interposition -flto -fuse-ld=gold' LD=/usr/bin/ld.gold
--prefix=/tools/emacs/build --sysconfdir=/etc
--libexecdir=/tools/emacs/build/usr/lib
--localstatedir=/tools/emacs/build/var --with-modules
--without-gconf --without-gsettings --enable-link-time-optimization
--with-x-toolkit=yes --without-xaw3d --without-m17n-flt --with-cairo
--with-xwidgets --without-compress-install
--with-native-compilation=aot --with-mailutils --with-xft --with-rsvg
--with-pgtk'
Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBOTF LIBSELINUX
LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP
SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM
XWIDGETS GTK3 ZLIB
Important settings:
value of $LC_ALL: C
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8
[-- Attachment #2: Type: text/html, Size: 7498 bytes --]
next reply other threads:[~2024-09-15 8:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-15 8:27 Iurie Marian [this message]
2024-09-16 17:21 ` bug#73270: 31.0.50; comp.el comp--type-check-optim pass causes issues Andrea Corallo
2024-10-15 8:35 ` Andrea Corallo
2024-10-15 20:22 ` Andrea Corallo
2024-10-15 20:29 ` Andrea Corallo
2024-10-18 17:52 ` Iurie Marian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP+jDP5vJn1M9hXSCdoRxuT=4iFQiK0E8Pge=xry-s6TV8qLdg@mail.gmail.com' \
--to=marian.iurie@gmail.com \
--cc=73270@debbugs.gnu.org \
--cc=acorallo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).