GNU bug report logs -
#30749
26.0.91; (cl-)case is confused when a nil atom is used instead of a keylist
Previous Next
Reported by: Alex Bennée <alex.bennee <at> linaro.org>
Date: Thu, 8 Mar 2018 10:29:02 UTC
Severity: minor
Tags: fixed
Found in version 26.0.91
Fixed in version 26.1
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 30749 in the body.
You can then email your comments to 30749 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30749
; Package
emacs
.
(Thu, 08 Mar 2018 10:29:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alex Bennée <alex.bennee <at> linaro.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 08 Mar 2018 10:29:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
I got confused why my case statement was failing as I'd used the second
form assuming that having nil as an atom would work. I'm not sure why
the quoting fixed it but it's certainly a confusing inconsistency. The
following behaviour shows up on emacs -Q:
(require 'cl)
(case nil
((nil) "nil")
((t) "default"))
"nil"
(case nil
(nil "nil")
(t "default"))
"default"
(case nil
('nil "nil")
('t "default"))
"nil"
(case t
('nil "nil")
('t "default"))
"default"
I think this is probably fixable with just making the docstring clearer
as the results of handling the duel atom/list of nil might have
unexpected results.
In GNU Emacs 26.0.91 (build 16, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2018-03-06 built on zen
Repository revision: 0efe0bd233de20bfb5bd9d06b255fc8ecf04602b
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description: Ubuntu 16.04.3 LTS
--
Alex Bennée
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30749
; Package
emacs
.
(Thu, 08 Mar 2018 11:12:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 30749 <at> debbugs.gnu.org (full text, mbox):
Alex Bennée <alex.bennee <at> linaro.org> writes:
> I got confused why my case statement was failing as I'd used the second
> form assuming that having nil as an atom would work. I'm not sure why
> the quoting fixed it but it's certainly a confusing inconsistency.
'nil is the same as (quote nil)
> I think this is probably fixable with just making the docstring clearer
> as the results of handling the duel atom/list of nil might have
> unexpected results.
So just add a "non-nil" perhaps?
--- i/lisp/emacs-lisp/cl-macs.el
+++ w/lisp/emacs-lisp/cl-macs.el
@@ -763,7 +763,7 @@ cl-case
"Eval EXPR and choose among clauses on that value.
Each clause looks like (KEYLIST BODY...). EXPR is evaluated and compared
against each key in each KEYLIST; the corresponding BODY is evaluated.
-If no clause succeeds, cl-case returns nil. A single atom may be used in
+If no clause succeeds, cl-case returns nil. A single non-nil atom may be used in
place of a KEYLIST of one atom. A KEYLIST of t or `otherwise' is
allowed only in the final clause, and matches if no other keys match.
Key values are compared by `eql'.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30749
; Package
emacs
.
(Thu, 08 Mar 2018 11:36:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 30749 <at> debbugs.gnu.org (full text, mbox):
Noam Postavsky <npostavs <at> gmail.com> writes:
> Alex Bennée <alex.bennee <at> linaro.org> writes:
>
>> I got confused why my case statement was failing as I'd used the second
>> form assuming that having nil as an atom would work. I'm not sure why
>> the quoting fixed it but it's certainly a confusing inconsistency.
>
> 'nil is the same as (quote nil)
Ahh so ends up as a list containing nil?
>
>> I think this is probably fixable with just making the docstring clearer
>> as the results of handling the duel atom/list of nil might have
>> unexpected results.
>
> So just add a "non-nil" perhaps?
>
> --- i/lisp/emacs-lisp/cl-macs.el
> +++ w/lisp/emacs-lisp/cl-macs.el
> @@ -763,7 +763,7 @@ cl-case
> "Eval EXPR and choose among clauses on that value.
> Each clause looks like (KEYLIST BODY...). EXPR is evaluated and compared
> against each key in each KEYLIST; the corresponding BODY is evaluated.
> -If no clause succeeds, cl-case returns nil. A single atom may be used in
> +If no clause succeeds, cl-case returns nil. A single non-nil atom may be used in
> place of a KEYLIST of one atom. A KEYLIST of t or `otherwise' is
> allowed only in the final clause, and matches if no other keys match.
> Key values are compared by `eql'.
Works for me.
--
Alex Bennée
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#30749
; Package
emacs
.
(Sat, 10 Mar 2018 22:59:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 30749 <at> debbugs.gnu.org (full text, mbox):
tags 30749 fixed
close 30749 26.1
quit
Alex Bennée <alex.bennee <at> linaro.org> writes:
> Noam Postavsky <npostavs <at> gmail.com> writes:
>
>> 'nil is the same as (quote nil)
>
> Ahh so ends up as a list containing nil?
Yup.
>> -If no clause succeeds, cl-case returns nil. A single atom may be used in
>> +If no clause succeeds, cl-case returns nil. A single non-nil atom may be used in
> Works for me.
Pushed to emacs-26.
[1: e244fed5e0]: 2018-03-10 17:56:04 -0500
Clarify that nil doesn't match itself as a cl-case clause (Bug#30749)
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=e244fed5e041c706dd10c60bd893634902f04aaa
Added tag(s) fixed.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 10 Mar 2018 22:59:01 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 26.1, send any further explanations to
30749 <at> debbugs.gnu.org and Alex Bennée <alex.bennee <at> linaro.org>
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 10 Mar 2018 22:59:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 08 Apr 2018 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 70 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.