GNU bug report logs - #21701
25.0.50; ert explainer for equal can't handle negative numbers (work in 24.5)

Previous Next

Package: emacs;

Reported by: Anders Lindgren <andlind <at> gmail.com>

Date: Sun, 18 Oct 2015 08:58:01 UTC

Severity: normal

Found in version 25.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #18 received at 21701-done <at> debbugs.gnu.org (full text, mbox):

From: Anders Lindgren <andlind <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 21701-done <at> debbugs.gnu.org
Subject: Re: Fwd: cl-typecase broken (was 25.0.50; ert explainer for equal
 can't handle negative numbers)
Date: Fri, 4 Dec 2015 16:41:46 +0100
[Message part 1 (text/plain, inline)]
Hi,

This should solve the immediate problem with negative numbers.

However, I gave this some though and realised that there is still a problem
with large numbers. For example:

(cl-typecase (+ (max-char) 1)
  (character "A character")
  (fixnum "A fixnum")
  (t "Something else"))

Returns "A character".

However, "(format "%c" (+ (max-char) 1))" raises the error
"(wrong-type-argument characterp 4194304)".

The question is if `cl-typecase', `format', and `characterp' should have
the same definition on what a character is. If not, then ERT must be
modified to handle this, e.g. by using `base-char' rather than `character'.

Personally, I would perfer if `character' would mean the same thing in all
contexts. I would suggest that we restore the old meaning of `character',
drop `base-char', and add a new type class, say `key-event', that could
include things like ?\M-\C-x.

    -- Anders

On Fri, Dec 4, 2015 at 2:30 PM, Stefan Monnier <monnier <at> iro.umontreal.ca>
wrote:

> > I just realised that the underlying problem is a change to `cl-typecase'.
> > It treats -50 as a character.
> >
> > (cl-typecase -50
> >   (character "A character")
> >   (fixnum "A fixnum")
> >   (t "Something else"))
> >
> > Emacs 25 returns "A character" and emacs 24 "A fixnum".
>
> I installed the patch below which should fix this.
>
>
>         Stefan
>
>
> diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
> index 09d2d3f..c8aad3a 100644
> --- a/lisp/emacs-lisp/cl-macs.el
> +++ b/lisp/emacs-lisp/cl-macs.el
> @@ -2885,7 +2885,7 @@ cl--macroexp-fboundp
>  (put 'real 'cl-deftype-satisfies #'numberp)
>  (put 'fixnum 'cl-deftype-satisfies #'integerp)
>  (put 'base-char 'cl-deftype-satisfies #'characterp)
> -(put 'character 'cl-deftype-satisfies #'integerp)
> +(put 'character 'cl-deftype-satisfies #'natnump)
>
>
>  ;;;###autoload
>
[Message part 2 (text/html, inline)]

This bug report was last modified 9 years and 166 days ago.

Previous Next


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