Declare nested backquotes unsupported in Pcase patterns (bug#72328)

The current behavior is inconsistent with that of the normal backquote
macro, so to avoid surprises, warn about the use of nested backquotes.

* lisp/emacs-lisp/pcase.el (pcase--expand-\`): Warn about nested backquotes.

* lisp/emacs-lisp/testcover.el (testcover-analyze-coverage)
(testcover-analyze-coverage-wrapped-form): Avoid nested backquotes
This commit is contained in:
Stefan Monnier 2024-09-24 14:01:26 -04:00
parent ce601de1ca
commit e8f5df5175
3 changed files with 8 additions and 3 deletions

View file

@ -1172,7 +1172,10 @@ The predicate is the logical-AND of:
(upatd (pcase--expand-\` (cdr qpat))))
(if (and (eq (car-safe upata) 'quote) (eq (car-safe upatd) 'quote))
`'(,(cadr upata) . ,(cadr upatd))
`(and (pred consp)
`(and ,@(when (eq (car qpat) '\`)
`((guard ,(macroexp-warn-and-return
"Nested ` are not supported" t nil nil qpat))))
(pred consp)
(app car-safe ,upata)
(app cdr-safe ,upatd)))))
((or (stringp qpat) (numberp qpat) (symbolp qpat)) `',qpat)

View file

@ -469,7 +469,7 @@ or return multiple values."
;; form to look odd. See bug#25316.
'testcover-1value)
(`(\` ,bq-form)
(`(,'\` ,bq-form)
(testcover-analyze-coverage-backquote-form bq-form))
((or 't 'nil (pred keywordp))
@ -548,7 +548,7 @@ FORM is treated as if it will be evaluated."
'testcover-1value))
((pred atom)
'testcover-1value)
(`(\` ,bq-form)
(`(,'\` ,bq-form)
(testcover-analyze-coverage-backquote-form bq-form))
(`(defconst ,sym ,val . ,_)
(push sym testcover-module-constants)