bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#57915: 29.0.50; Misleading warning about use of quote in clause of c


From: Jonas Bernoulli
Subject: bug#57915: 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]