[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16201: 24.3.50; error expanding pcase with a pred clause
From: |
Michael Heerdegen |
Subject: |
bug#16201: 24.3.50; error expanding pcase with a pred clause |
Date: |
Sat, 21 Dec 2013 12:54:21 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Michael Heerdegen <michael_heerdegen@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.