On Sat, Aug 29, 2020 at 12:01 PM Philipp Stephani wrote: > Am Sa., 29. Aug. 2020 um 11:42 Uhr schrieb Pip Cet : > > I'm having trouble with pcase's behavior. > > > > (pcase "a" > > ((or (pred symbolp) name) > > (let ((foo 'bar)) name))) > > > > throws an error. It shouldn't. > > Isn't this case documented in the manual? The last section of > https://www.gnu.org/software/emacs/manual/html_node/elisp/pcase-Macro.html > states: > "It makes no sense for each sub-pattern [in an `or' sequence] to > let-bind a different set of symbols because the body forms have no way > to distinguish which sub-pattern matched and choose among the > different sets." Thanks for pointing this out. I disagree with what the documentation says there: it does make perfect sense, to me, to conditionally shadow a (lexical) let binding with a pcase-let one, and body forms will have no trouble in practice distinguishing between the outer and the inner let-binding. The code obviously attempts to handle this case, too, it just doesn't get it perfectly right. I agree and accept that pcase is very limited, and it probably always will be, but I think those limitations shouldn't be entirely arbitrary, and hitting them shouldn't cause silently malfunctioning code but error messages. Things like the behavior of (pcase-let ((`(,a ,@b) (list 3 4))) a) just seem puzzling to me. There are good reasons not to implement sublist matching (though I don't think those reasons are sufficient not to have a simple implementation anyway), so an error message would be acceptable, but the current implementation treats \,@ as an ordinary symbol, which doesn't help anyone. Sorry for complaining. Here's a patch.