Subject: Re: bug#14773: 24.2; pcase

From: Stefan Monnier <[email-masked]>
Date: Wed, 03 Jul 2013 05:34:59 -0400

> (require 'pcase)
> (macroexpand
>    '(pcase 1
>       ((and (let var left) (guard var)) 'left)
>       ((and (let var right) (guard var)) 'right)))

> When I run this, the result I get is (let ((x 1)) (if (let* ((var left))
> var) (let ((var left)) (quote left)) nil)).  Note that "right" doesn't
> appear anywhere in the macro expansion!

Since the second branch of your pcase is unreachable, I think it's OK
for pcase to eliminate it.

Note that it output the message "Redundant pcase pattern: (and (let var
right) (guard var))" which explains the behavior.

This said, I can't remember making this optimization so aggressive (it
seems correct here, but it seems difficult to avoid similar incorrect
ones), so I wouldn't be surprised if there are other cases where it gets
it wrong.

Could it be that you had another (real) problem and that the above
example is a (too) simplified test case you extracted from it?

        Stefan