From mboxrd@z Thu Jan 1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Philipp Stephani
Newsgroups: gmane.emacs.bugs
Subject: bug#51368: 29.0.50; `cl-case' should error on incorrect use
Date: Sun, 31 Oct 2021 19:53:53 +0100
Message-ID:
References: <87a6iy71q1.fsf@gnus.org>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
logging-data="1093"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: 51368@debbugs.gnu.org
To: Lars Ingebrigtsen
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 31 19:55:32 2021
Return-path:
Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.92)
(envelope-from )
id 1mhFzP-000Ae1-4B
for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 Oct 2021 19:55:31 +0100
Original-Received: from localhost ([::1]:44014 helo=lists1p.gnu.org)
by lists.gnu.org with esmtp (Exim 4.90_1)
(envelope-from )
id 1mhFzN-0007zp-MV
for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 Oct 2021 14:55:29 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40760)
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from )
id 1mhFyy-0007xa-Lr
for bug-gnu-emacs@gnu.org; Sun, 31 Oct 2021 14:55:04 -0400
Original-Received: from debbugs.gnu.org ([209.51.188.43]:49807)
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
(Exim 4.90_1) (envelope-from )
id 1mhFyw-0001w0-5t
for bug-gnu-emacs@gnu.org; Sun, 31 Oct 2021 14:55:04 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
(envelope-from ) id 1mhFyw-0000kJ-1d
for bug-gnu-emacs@gnu.org; Sun, 31 Oct 2021 14:55:02 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Philipp Stephani
Original-Sender: "Debbugs-submit"
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Sun, 31 Oct 2021 18:55:01 +0000
Resent-Message-ID:
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 51368
X-GNU-PR-Package: emacs
Original-Received: via spool by 51368-submit@debbugs.gnu.org id=B51368.16357064512803
(code B ref 51368); Sun, 31 Oct 2021 18:55:01 +0000
Original-Received: (at 51368) by debbugs.gnu.org; 31 Oct 2021 18:54:11 +0000
Original-Received: from localhost ([127.0.0.1]:33120 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from )
id 1mhFy6-0000j9-Tw
for submit@debbugs.gnu.org; Sun, 31 Oct 2021 14:54:11 -0400
Original-Received: from mail-ot1-f43.google.com ([209.85.210.43]:46980)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from ) id 1mhFy5-0000iw-KI
for 51368@debbugs.gnu.org; Sun, 31 Oct 2021 14:54:10 -0400
Original-Received: by mail-ot1-f43.google.com with SMTP id
x27-20020a9d459b000000b0055303520cc4so22221464ote.13
for <51368@debbugs.gnu.org>; Sun, 31 Oct 2021 11:54:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=9kVO8K1ANUg1/8pN5wZjmXObZ+hNrdW4ye31GTld0qQ=;
b=lfGosQsY0J5XrtQnsGDj19Q/6EH4wn3gqPH22CxSPxRaKByERpuY908nw6Keg/cc7i
PD2i+QK3oJOnmhKTitm1kuJkHDH5Onzwj3R/H4sYa/4USjl15Y3E8b7aqr/XWQYrTjH6
Rcmq/K0Jxo1iweeaZfEhJFVGU7rneZu5JPLEiYJpORjRje3nmyQOumF5kKpsLlWUDkWQ
jMeUuu6tKcfD5tWw0eKVk040RLQrHZ6uQHmhbQJ3U3PAjevpDdzHWw8r9D2MFihtt8sF
E/RtJNnH87x8P+hG5N1PRUiNFADxYKwr5+rxOiOTBSyklP/rCqBWjP4CKU/oYwNKc9kg
uhXQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=9kVO8K1ANUg1/8pN5wZjmXObZ+hNrdW4ye31GTld0qQ=;
b=tMlRMgKw6TzH1OlDjRzR/8CYUxPfPR/VPkAmtQXK7O2w+2LmANDutmBeQdw3I0PbsF
V4U84WAQ2sItqm71O1SNsv50e8wIpKI8c22YpqwbACLOwVOQJxcdSJ3X+9HpkH2aapUw
q+BpW0KMoB+yNFxFixMro8B586s2RI40iZVBA0Jyans9tpfgOdSmw4rwGMdseoCtZKq7
3MVWL5GwQ37OWGev68lX/tQKDvdmePrmOdJpyXbbET/CL1gxXwl3UccT5Ej/aEyVGquq
FG5Kk1Dp5z4eRIgEJ9u51U2vKHGxgISEM/ubEVDjKe3hBjQZRE52G95n4iix2Y7NUhLa
W+jg==
X-Gm-Message-State: AOAM532Y5udyGN/Ogn/MueQMIckU8QGdqt8ATDEzeiQWmqM/V6YdV/uw
mENOHLFaKjF+xQlEj1u1WFVZf/2ziXdz/mV7QbE=
X-Google-Smtp-Source: ABdhPJyJmT5JJ18hTo9XrllZrCgyjznqOWYpxKvEFFCfdXQ6GnbFUof3OiIKh+rCYAWG/TcpSyfeLPnZV2B2RljO5OM=
X-Received: by 2002:a9d:669:: with SMTP id 96mr18214145otn.224.1635706443845;
Sun, 31 Oct 2021 11:54:03 -0700 (PDT)
In-Reply-To: <87a6iy71q1.fsf@gnus.org>
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
the Swiss army knife of text editors"
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: "bug-gnu-emacs"
Xref: news.gmane.io gmane.emacs.bugs:218715
Archived-At:
Am So., 24. Okt. 2021 um 19:48 Uhr schrieb Lars Ingebrigtsen :
>
> Philipp Stephani writes:
>
> > This form demonstrates a few incorrect uses of `cl-case':
> >
> > (cl-case a
> > (nil 0) ; doesn't match anything
> > (t 1) ; matches everything, but too early
> > ('foo 2)) ; matches `quote' in addition to `foo'
> >
> > It would be nice if `cl-case' would signal an error or at least warn
> > about these at macroexpansion time, since they are somewhat subtle and
> > easy to get wrong.
>
> An error from the second case would be nice, and a warning on the first
> case, but the third case:
>
> (macroexpand
> '(cl-case a
> ('foo (message "foo"))))
> => (cond ((cl-member a ''foo) (message "foo")))
>
> and
>
> (equal ''foo (list 'quote 'foo))
>
> which, sure, whatever. But I guess the question is whether we can
> actually warn about that, because to the reader, the two forms are
> equivalent?
Yes, but the problem only arises if the user wants to match the symbol
`quote' plus exactly one other value. That should already be
exceedingly rare, and can be trivially rewritten by swapping the two
values (i.e. write (foo quote) instead of (quote foo)). So I think
issuing a warning or error for that case is worth it.
Assuming we'd want to prevent similar bugs with other reader
constructs, I think the only real problematic case is matching exactly
two of the symbols `function', `quote', `,', `,@', and `\`'. Maybe for
those cases we should just instruct people to write (cond (memq ...))
or similar.