unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: John Williams <jrw@google.com>
Cc: 14773@debbugs.gnu.org
Subject: bug#14773: 24.2; pcase
Date: Wed, 03 Jul 2013 05:34:59 -0400	[thread overview]
Message-ID: <jwv1u7gyoq9.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <wec8wqp8k6d5.fsf@tartarus.kir.corp.google.com> (John Williams's message of "Tue, 02 Jul 2013 14:19:02 -0700")

> (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





  reply	other threads:[~2013-07-03  9:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02 21:19 bug#14773: 24.2; pcase John Williams
2013-07-03  9:34 ` Stefan Monnier [this message]
2013-07-03 16:53   ` Michael Heerdegen
2013-07-03 22:53     ` Stefan Monnier
2013-07-08 21:56     ` Stefan Monnier

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=jwv1u7gyoq9.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=14773@debbugs.gnu.org \
    --cc=jrw@google.com \
    /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).