GNU bug report logs - #57915
29.0.50; Misleading warning about use of quote in clause of cl-case

Previous Next

Package: emacs;

Reported by: Jonas Bernoulli <jonas <at> bernoul.li>

Date: Sun, 18 Sep 2022 19:36:02 UTC

Severity: normal

Tags: moreinfo

Found in version 29.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jonas Bernoulli <jonas <at> bernoul.li>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; Misleading warning about use of quote in clause of cl-case
Date: Sun, 18 Sep 2022 21:35:31 +0200
I inherited some code like this:

  (cl-case foo
    ((quote) ...)
    ((funcall) ...))

While I probably would not have written it like this, I think it
makes sense, since (quote ...) looks like ... is being quoted.  Using
((quote) ...) make it clear to the human reader that that is not what is
happening.  Unfortunately the byte-compiler now provides this misleading
warning:

  Warning: Case (quote) will match ‘quote’.  If that’s intended,
    write (nil quote) instead.  Otherwise, don’t quote ‘nil’.

This is misleading because the conditions (quote) and (nil quote) are
not equivalent; obviously the first only matches `quote', while second
also matches nil.  I have seen this exact warning for a few other
packages and fear that someone might blindly follow the suggestion.

Could this special case, (quote), be handled differently?  I understand
we want to catch, pcase-inspired clauses like 'x.  I am not sure we can
tell the difference between (quote), (quote nil) and 'nil, but it seems
to me, that if that is not the case, we should avoid the invalid
recommendation at the cost of not warning about the other, likely
unintended uses.

    Cheers,
    Jonas




This bug report was last modified 2 years and 303 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.