[Top][All Lists]

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

bug#21701: Fwd: cl-typecase broken (was 25.0.50; ert explainer for equal

From: Anders Lindgren
Subject: bug#21701: 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


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 <address@hidden> 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.


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)


reply via email to

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