all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#59814: 28.2; `rx-let` bindings are not visible to `pcase` `rx` forms
@ 2022-12-04 11:03 Daniel Pittman
  2022-12-04 14:37 ` Mattias Engdegård
  2022-12-11 16:14 ` bug#59814: 28.2; `rx-let` bindings are not visible to `pcase` `rx` Mattias Engdegård
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Pittman @ 2022-12-04 11:03 UTC (permalink / raw)
  To: 59814

[-- Attachment #1: Type: text/plain, Size: 18477 bytes --]

Local rx bindings through the `rx-let` form are not visible to rx
expressions during `pcase` expansion:

(rx-let ((bug "demo")) (rx bug))
=> "demo"

(pcase "demo" ((rx "demo") t))
=> t

(rx-let ((bug "demo")) (pcase "demo" ((rx bug) t)))
=> (error "Unknown rx symbol ‘bug’")
=> ;; expected: t

It looks like `rx--pcase-macroexpander` isn't correctly passing the
:rx-local binding out of the macroexpansion environment into the
translation functions, or something like that.

In GNU Emacs 28.2 (build 2, x86_64-w64-mingw32)
 of 2022-09-13 built on AVALON
Windowing system distributor 'Microsoft Corp.', version 10.0.22000
System Description: Microsoft Windows 10 Pro (v10.0.2009.22000.1219)

Configured using:
 'configure --with-modules --without-dbus --with-native-compilation
 --without-compress-install CFLAGS=-O2'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
XPM ZLIB

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

Major mode: ELisp/l

Minor modes in effect:
  treemacs-filewatch-mode: t
  treemacs-follow-mode: t
  treemacs-git-mode: deferred
  treemacs-fringe-indicator-mode: t
  dap-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  highlight-defined-mode: t
  lexbind-mode: t
  rainbow-delimiters-mode: t
  ws-butler-mode: t
  global-cwarn-mode: t
  global-atomic-chrome-edit-mode: t
  shell-dirtrack-mode: t
  global-auto-revert-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  smart-yank-mode: t
  global-anzu-mode: t
  anzu-mode: t
  save-place-mode: t
  beginend-global-mode: t
  beginend-prog-mode: t
  cascading-dir-locals-mode: t
  midnight-mode: t
  desktop-save-mode: t
  persistent-scratch-autosave-mode: t
  async-bytecomp-package-mode: t
  el-patch-use-package-mode: t
  gcmh-mode: t
  which-key-mode: t
  global-dash-fontify-mode: t
  dash-fontify-mode: t
  override-global-mode: t
  straight-use-package-mode: t
  straight-package-neutering-mode: t
  straight-symlink-emulation-mode: t
  straight-live-modifications-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-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
  temp-buffer-resize-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
c:/Users/danie/.emacs.d/straight/build/transient/transient hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/transient
c:/Users/danie/.emacs.d/straight/build/less-css-mode/less-css-mode hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/textmodes/less-css-mode
c:/Users/danie/.emacs.d/straight/build/xref/xref hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/progmodes/xref
c:/Users/danie/.emacs.d/straight/build/project/project hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/progmodes/project
c:/Users/danie/.emacs.d/straight/build/tramp/trampver hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/trampver
c:/Users/danie/.emacs.d/straight/build/tramp/tramp hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-uu hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-uu
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-sudoedit hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-sudoedit
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-sshfs hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-sshfs
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-smb hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-smb
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-sh hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-sh
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-rclone hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-rclone
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-integration hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-integration
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-gvfs hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-gvfs
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-fuse hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-fuse
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-ftp hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-ftp
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-crypt hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-crypt
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-compat hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-compat
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-cmds hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-cmds
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-cache hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-cache
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-archive hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-archive
c:/Users/danie/.emacs.d/straight/build/tramp/tramp-adb hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/net/tramp-adb
c:/Users/danie/.emacs.d/straight/build/let-alist/let-alist hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/emacs-lisp/let-alist
c:/Users/danie/.emacs.d/straight/build/faceup/faceup hides
c:/Users/danie/scoop/apps/emacs/current/share/emacs/28.2/lisp/emacs-lisp/faceup

Features:
(mail-extr emacsbug sendmail magit-patch magit-subtree magit-gitignore
magit-ediff ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help
ediff-init ediff-util eieio-opt shortdoc find-dired wgrep grep
pcmpl-unix em-unix em-term term ehelp em-smart em-script em-prompt em-ls
em-hist em-pred em-glob em-cmpl em-dirs esh-var em-basic em-banner
em-alias esh-mode eshell macrostep gitignore-mode conf-mode
git-modes-autoloads thai-util thai-word descr-text esh-cmd esh-ext
esh-opt esh-proc esh-io esh-arg esh-module esh-groups esh-util pcre2el
rxt cl-print cl-indent misc string-inflection novice magit-extras
re-builder two-column sort ispell tabify dired-filter dired-hacks-utils
dired-x shadow tree-sitter-langs tree-sitter-langs-build tar-mode
tree-sitter-hl tree-sitter tree-sitter-load tree-sitter-cli tsc tsc-dyn
tsc-dyn-get tsc-obsolete tree-sitter-langs-autoloads
tree-sitter-autoloads tsc-autoloads autoload swap-buffers quail vc-mtn
vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs vc-hgcmd vc-dir face-remap
forge-list forge-commands forge-semi forge-bitbucket buck forge-gogs
gogs forge-gitea gtea forge-gitlab glab forge-github ghub-graphql treepy
gsexp ghub forge-notify forge-revnote forge-pullreq forge-issue
forge-topic yaml bug-reference forge-post forge-repo forge forge-core
forge-db closql emacsql-sqlite emacsql emacsql-compiler magit-submodule
magit-obsolete magit-popup magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log which-func wdired
xterm-color ialign helpful trace edebug info-look help-fns radix-tree
elisp-refs visual-regexp move-text executable time-stamp hippie-exp
misearch multi-isearch cursor-sensor view lsp-zig lsp-steep lsp-svelte
lsp-sqls lsp-yaml lsp-xml lsp-vimscript lsp-vhdl lsp-vetur lsp-html
lsp-verilog lsp-vala lsp-v lsp-terraform lsp-tex lsp-sorbet
lsp-solargraph lsp-rust lsp-rf lsp-r lsp-purescript lsp-pylsp lsp-pyls
lsp-pwsh lsp-php lsp-perl lsp-ocaml lsp-nix lsp-nim lsp-markdown lsp-lua
lsp-kotlin lsp-json lsp-javascript dap-java lsp-java lsp-treemacs
lsp-treemacs-themes treemacs treemacs-header-line treemacs-compatibility
treemacs-mode treemacs-interface treemacs-extensions
treemacs-mouse-interface treemacs-tags treemacs-persistence
treemacs-filewatch-mode treemacs-follow-mode treemacs-rendering
treemacs-async treemacs-workspaces treemacs-dom treemacs-visuals
treemacs-fringe-indicator treemacs-scope treemacs-faces treemacs-icons
treemacs-themes treemacs-core-utils pfuture hl-line treemacs-logging
treemacs-customization treemacs-macros lsp-haxe lsp-groovy lsp-hack
lsp-go lsp-completion lsp-gdscript lsp-fsharp lsp-fortran lsp-eslint
lsp-erlang lsp-elixir lsp-elm lsp-dockerfile lsp-dhall lsp-d lsp-css
lsp-csharp gnutls lsp-crystal lsp-cmake lsp-clojure lsp-semantic-tokens
lsp-clangd lsp-beancount lsp-bash lsp-angular lsp-ada lsp-actionscript
yaml-mode highlight-indent-guides smart-jump-python python generic
json-mode json-reformat json-snatcher js bat-mode speedbar ezimage
dframe powershell info-colors mule-util rng-xsd xsd-regexp rng-cmpct
whattf-dt rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse
rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln
nxml-rap nxml-util nxml-enc xmltok lua-mode arc-mode archive-mode
dired-aux smart-jump-csharp-mode csharp-mode csharp-compilation cc-langs
dap-mode dap-launch posframe dap-overlays lsp-mode lsp-protocol
tree-widget wid-edit network-stream markdown-mode edit-indirect noutline
outline inline ht vc-git magit-diff smerge-mode git-commit log-edit
message dired dired-loaddefs rfc822 mml mml-sec epa gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mailabbrev gmm-utils
pcvs-util add-log magit-core magit-autorevert magit-margin
magit-transient magit-process magit-mode transient magit-git
magit-section magit-utils crm diff-mode autoinsert figlet-autoloads
julia-mode-autoloads ess-autoloads sayid-autoloads sayid
highlight-defined lexbind-mode rainbow-delimiters ws-butler
smart-jump-clojure-mode clj-refactor pkg-info url-http url-auth url-gw
nsm rmc puny epl cap-words superword subword hydra lv inflections
sgml-mode facemenu dom cider tramp-sh cider-debug cider-browse-ns
cider-mode cider-inspector cider-completion cider-profile cider-eval
cider-repl-history pulse cider-repl cider-resolve cider-test
nobreak-fade cider-overlays cider-stacktrace cider-doc cider-browse-spec
cider-clojuredocs cider-eldoc cider-client cider-common cider-connection
cider-util cider-popup sesman-browser nrepl-client kubernetes-tramp
docker-tramp tramp-cache tramp tramp-loaddefs trampver tramp-integration
files-x tramp-compat parse-time iso8601 time-date format-spec sesman vc
vc-dispatcher queue nrepl-dict cider-compat spinner parseedn
parseclj-parser parseclj-lex clojure-mode align
mc-hide-unmatched-lines-mode mc-mark-more mc-cycle-cursors
multiple-cursors-core rect paredit clj-refactor-compat
clj-refactor-autoloads paredit-autoloads clj-decompiler-autoloads
cider-autoloads sesman-autoloads parseedn-autoloads parseclj-autoloads
clojure-mode-autoloads racket-mode-autoloads pos-tip-autoloads
faceup-autoloads mermaid-mode-autoloads plantuml-mode-autoloads
graphviz-dot-mode-autoloads lexbind-mode-autoloads macrostep-autoloads
highlight-defined-autoloads cl-lib-highlight cl-lib-highlight-autoloads
cl-libify-autoloads derived protobuf-mode-autoloads go-mode-autoloads
csharp-mode-autoloads glsl-mode-autoloads groovy-mode-autoloads
lsp-java-autoloads dap-mode-autoloads lsp-treemacs-autoloads
bui-autoloads treemacs-autoloads cfrs-autoloads posframe-autoloads
pfuture-autoloads ace-window-autoloads avy-autoloads
lsp-sourcekit-autoloads swift-helpful-autoloads swift-mode-autoloads
cwarn hy-mode-autoloads python-docstring-autoloads zimports-autoloads
projectile-autoloads pip-requirements-autoloads sql-indent-autoloads
apples-mode-autoloads jq-mode-autoloads jsonnet-mode-autoloads
smart-jump-typescript-mode tide tide-lv imenu flycheck etags fileloop
generator typescript-mode compile text-property-search tide-autoloads
typescript-mode-autoloads indium-autoloads json-process-client-autoloads
company-autoloads js2-refactor-autoloads multiple-cursors-autoloads
add-node-modules-path-autoloads rjsx-mode-autoloads js2-mode-autoloads
rustic-autoloads homebrew-mode-autoloads inf-ruby-autoloads
pcmpl-homebrew-autoloads yard-mode-autoloads puppet-mode-autoloads
toml-mode-autoloads lua-mode-autoloads powershell-mode-autoloads
powershell-autoloads rmsbolt-autoloads smart-jump-lisp-mode
smart-jump-elisp-mode smart-jump-cc-mode smart-jump xref project
smart-jump-autoloads dumb-jump-autoloads popup-autoloads
highlight-indent-guides-autoloads lsp-ui-autoloads lsp-mode-autoloads
flycheck-autoloads pkg-info-autoloads epl-autoloads
cmake-font-lock-autoloads cmake-mode-autoloads bazel-autoloads
caddyfile-mode-autoloads loop-autoloads generic-x cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
ialign-autoloads nginx-mode-autoloads apache-mode-autoloads
systemd-autoloads ssh-config-mode-autoloads elquery-autoloads
esxml-autoloads kv-autoloads less-css-mode-autoloads rnc-mode-autoloads
jira-markup-mode-autoloads pandoc-mode-autoloads hydra-autoloads
lv-autoloads ws-butler-autoloads peep-dired-autoloads
dired-filter-autoloads dired-hacks-utils-autoloads esh-help-autoloads
xterm-color-autoloads vterm-autoloads atomic-chrome websocket bindat
let-alist atomic-chrome-autoloads websocket-autoloads gist-autoloads
gh-autoloads marshal-autoloads ht-autoloads logito-autoloads
forge-autoloads yaml-autoloads markdown-mode-autoloads ghub-autoloads
treepy-autoloads let-alist-autoloads closql-autoloads
emacsql-sqlite-autoloads emacsql-autoloads magit-autoloads
git-commit-autoloads hg-histedit with-editor shell pcomplete comint
ansi-color ring server hg-histedit-autoloads hgignore-mode-autoloads
hgrc-mode-autoloads vc-hgcmd-autoloads project-autoloads xref-autoloads
activity-watch-mode request mailheader autorevert filenotify mail-utils
ert pp ewoc debug backtrace activity-watch-mode-autoloads spdx-autoloads
yasnippet yasnippet-autoloads info-colors-autoloads tldr-autoloads
request-autoloads helpful-autoloads elisp-refs-autoloads
kubernetes-tramp-autoloads kubernetes-autoloads with-editor-autoloads
magit-popup-autoloads magit-section-autoloads docker-autoloads
tablist-autoloads json-mode-autoloads json-snatcher-autoloads
json-reformat-autoloads docker-tramp-autoloads dockerfile-mode-autoloads
docker-compose-mode-autoloads yaml-mode-autoloads
copy-file-on-save-autoloads undo-tree diff undo-tree-autoloads
smart-yank smart-yank-autoloads swap-buffers-autoloads rg-autoloads
wgrep-autoloads transient-autoloads anzu thingatpt anzu-autoloads
loccur-autoloads affe-autoloads consult-autoloads orderless-autoloads
list-unicode-display-autoloads expand-region-autoloads saveplace
uuidgen-autoloads urlenc-autoloads beginend cus-load beginend-autoloads
move-text-autoloads typo-autoloads literal-string-autoloads
edit-indirect-autoloads replace-with-inflections-autoloads
inflections-autoloads string-inflection-autoloads
toggle-quotes-autoloads nobreak-fade-autoloads visual-regexp-autoloads
pcre2el-autoloads rainbow-mode-autoloads rainbow-delimiters-autoloads
epoch-view-autoloads cascading-dir-locals cascading-dir-locals-autoloads
color dracula-theme dracula-theme-autoloads show-font-mode-autoloads
font-utils font-utils-autoloads persistent-soft-autoloads
list-utils-autoloads midnight edmacro kmacro desktop frameset
persistent-scratch persistent-scratch-autoloads tramp-autoloads
spinner-autoloads epg rfc6068 epg-config auto-minor-mode
auto-minor-mode-autoloads pcache-autoloads noflet-autoloads
bug-hunter-autoloads async-bytecomp async async-autoloads
cl-format-autoloads a el-patch a-autoloads trie-autoloads heap-autoloads
tNFA-autoloads queue-autoloads f f-autoloads s s-autoloads macro-utils
cl restart-emacs-autoloads gcmh gcmh-autoloads delight comp comp-cstr
warnings which-key advice which-key-autoloads pcase delight-autoloads
dash dash-autoloads el-patch-autoloads use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode use-package-core straight-recipes bootstrapped-my-emacs
use-package-autoloads bind-key-autoloads straight-autoloads info
cl-extra help-mode straight finder finder-inf find-func lisp-mnt
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json map url-vars seq byte-opt gv bytecomp byte-compile
cconv cl-loaddefs cl-lib rx subr-x early-init iso-transl tooltip eldoc
paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
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 lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax 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 emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 4646095 1709679)
 (symbols 48 147702 3)
 (strings 32 420625 259639)
 (string-bytes 1 15079671)
 (vectors 16 211346)
 (vector-slots 8 5117651 1300452)
 (floats 8 508 2192)
 (intervals 56 400787 35018)
 (buffers 992 623))

[-- Attachment #2: Type: text/html, Size: 19298 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#59814: 28.2; `rx-let` bindings are not visible to `pcase` `rx` forms
  2022-12-04 11:03 bug#59814: 28.2; `rx-let` bindings are not visible to `pcase` `rx` forms Daniel Pittman
@ 2022-12-04 14:37 ` Mattias Engdegård
  2022-12-11 16:14 ` bug#59814: 28.2; `rx-let` bindings are not visible to `pcase` `rx` Mattias Engdegård
  1 sibling, 0 replies; 3+ messages in thread
From: Mattias Engdegård @ 2022-12-04 14:37 UTC (permalink / raw)
  To: 59814; +Cc: Daniel Pittman

[-- Attachment #1: Type: text/plain, Size: 41 bytes --]

That's terrible. Would this patch help?


[-- Attachment #2: 0001-Fix-pcase-rx-patterns-using-rx-let-bindings-bug-5981.patch --]
[-- Type: application/octet-stream, Size: 2627 bytes --]

From 30894f0ed19572b6b55dfb791a8fd8a84bfd660a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Sun, 4 Dec 2022 15:20:49 +0100
Subject: [PATCH] Fix pcase rx patterns using rx-let bindings (bug#59814)

Reported by Daniel Pittman.

* lisp/emacs-lisp/rx.el (rx): Move binding of rx--local-definitions...
(rx--to-expr): ...here.
* test/lisp/emacs-lisp/rx-tests.el (rx-let-pcase): New test.
---
 lisp/emacs-lisp/rx.el            | 14 +++++++-------
 test/lisp/emacs-lisp/rx-tests.el |  6 ++++++
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index ec51146484..f2a0dc5483 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -1152,7 +1152,12 @@ rx-to-string
 
 (defun rx--to-expr (form)
   "Translate the rx-expression FORM to a Lisp expression yielding a regexp."
-  (let* ((rx--delayed-evaluation t)
+  (let* ((rx--local-definitions
+          ;; Retrieve local definitions from the macroexpansion environment.
+          ;; (It's unclear whether the previous value of `rx--local-definitions'
+          ;; should be included, and if so, in which order.)
+          (cdr (assq :rx-locals macroexpand-all-environment)))
+         (rx--delayed-evaluation t)
          (elems (car (rx--translate form)))
          (args nil))
     ;; Merge adjacent strings.
@@ -1282,12 +1287,7 @@ rx
 which see.
 
 \(fn REGEXPS...)"
-  ;; Retrieve local definitions from the macroexpansion environment.
-  ;; (It's unclear whether the previous value of `rx--local-definitions'
-  ;; should be included, and if so, in which order.)
-  (let ((rx--local-definitions
-         (cdr (assq :rx-locals macroexpand-all-environment))))
-    (rx--to-expr (cons 'seq regexps))))
+  (rx--to-expr (cons 'seq regexps)))
 
 (defun rx--make-binding (name tail)
   "Make a definitions entry out of TAIL.
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el
index 125ddee859..01772e54d8 100644
--- a/test/lisp/emacs-lisp/rx-tests.el
+++ b/test/lisp/emacs-lisp/rx-tests.el
@@ -207,6 +207,12 @@ rx-pcase
                    (list 'ok z))
                  '(ok "F"))))
 
+(ert-deftest rx-let-pcase ()
+  "Test `rx-let' around `pcase' with `rx' patterns (bug#59814)."
+  (should (equal (rx-let ((tata "ab"))
+                   (pcase "abc" ((rx tata) 'toto)))
+                 'toto)))
+
 (ert-deftest rx-kleene ()
   "Test greedy and non-greedy repetition operators."
   (should (equal (rx (* "a") (+ "b") (\? "c") (?\s "d")
-- 
2.32.0 (Apple Git-132)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#59814: 28.2; `rx-let` bindings are not visible to `pcase` `rx`
  2022-12-04 11:03 bug#59814: 28.2; `rx-let` bindings are not visible to `pcase` `rx` forms Daniel Pittman
  2022-12-04 14:37 ` Mattias Engdegård
@ 2022-12-11 16:14 ` Mattias Engdegård
  1 sibling, 0 replies; 3+ messages in thread
From: Mattias Engdegård @ 2022-12-11 16:14 UTC (permalink / raw)
  To: 59814-done; +Cc: Daniel Pittman

The patch has now been pushed to emacs-29. Thanks for the report!






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-11 16:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-04 11:03 bug#59814: 28.2; `rx-let` bindings are not visible to `pcase` `rx` forms Daniel Pittman
2022-12-04 14:37 ` Mattias Engdegård
2022-12-11 16:14 ` bug#59814: 28.2; `rx-let` bindings are not visible to `pcase` `rx` Mattias Engdegård

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.