GNU bug report logs - #16201
24.3.50; error expanding pcase with a pred clause

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Fri, 20 Dec 2013 14:47:02 UTC

Severity: normal

Found in version 24.3.50

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

Bug is archived. No further changes may be made.

Full log


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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: 16201 <at> debbugs.gnu.org
Subject: Re: bug#16201: 24.3.50; error expanding pcase with a pred clause
Date: Sat, 21 Dec 2013 12:54:21 +0100
Michael Heerdegen <michael_heerdegen <at> web.de> writes:


> (defun test-buffer-file-name ()
>   (pcase buffer-file-name
>     (`nil                   'not-a-file)
>     ((pred file-writable-p) 'writable)
>     (_                      'not-writable)))
>
>   pcase-bug.el:3:1:Error: Wrong type argument: stringp, nil

pcase seems to test whether the constant (nil) from the first clause
fulfills the pred of the second clause.  Which is not legal in this
case.

I thought this could be ok:

(pcase buffer-file-name
    (`nil                   'not-a-file)
    ((and (pred stringp)
	  (pred file-writable-p)) 'writable)
    (_                      'not-writable))

but that triggers the same error.

This works, however, but doesn't look so nice:

  (pcase buffer-file-name
    (`nil                   'not-a-file)
    ((pred (lambda (x) (and (stringp x) (file-writable-p x)))) 'writable)
    (_                      'not-writable))


Regards,

Michael.




This bug report was last modified 11 years and 201 days ago.

Previous Next


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