GNU bug report logs -
#9035
24.0.50; byte-compiler warnings with defstruct and lexical-binding
Previous Next
Reported by: Lawrence Mitchell <wence <at> gmx.li>
Date: Sat, 9 Jul 2011 14:35:01 UTC
Severity: minor
Tags: fixed, patch
Found in version 24.0.50
Fixed in version 24.1
Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
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 9035 in the body.
You can then email your comments to 9035 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9035
; Package
emacs
.
(Sat, 09 Jul 2011 14:35:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Lawrence Mitchell <wence <at> gmx.li>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 09 Jul 2011 14:35:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
In files with lexical-binding set to t, structure definitions
with :read-only slots lead to a byte-compiler warning about
the unused variable cl-x.
To reproduce, byte-compile a file consisting of:
;; -*- lexical-binding: t -*-
(eval-when-compile (require 'cl))
(defstruct foo (name nil :read-only t))
This is due to the setf-method that is produced when expanding
the defstruct form:
(define-setf-method ... (cl-x)
(error (format "%s is a read-only slot" ...)))
The following patch fixes the problem by changing the setf-method
to:
(define-setf-method ... (cl-x)
(progn (ignore cl-x)
(error (format "%s is a read-only slot" ...))))
Commit message/changelog entry
Silence byte-compiler warning with :read-only defstruct slots
* emacs-lisp/cl-macs.el (defstruct): Ignore argument to setf method if
slot is read-only.
Patch:
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 2813cc4..6181c6b 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2389,8 +2389,10 @@ value, that slot cannot be set via `setf'.
(push (cons accessor t) side-eff)
(push (list 'define-setf-method accessor '(cl-x)
(if (cadr (memq :read-only (cddr desc)))
- (list 'error (format "%s is a read-only slot"
- accessor))
+ (list 'progn '(ignore cl-x)
+ (list 'error
+ (format "%s is a read-only slot"
+ 'accessor)))
;; If cl is loaded only for compilation,
;; the call to cl-struct-setf-expander would
;; cause a warning because it may not be
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9035
; Package
emacs
.
(Sat, 16 Jul 2011 15:54:03 GMT)
Full text and
rfc822 format available.
Message #8 received at 9035 <at> debbugs.gnu.org (full text, mbox):
Lawrence Mitchell <wence <at> gmx.li> writes:
> The following patch fixes the problem by changing the setf-method
> to:
>
> (define-setf-method ... (cl-x)
> (progn (ignore cl-x)
> (error (format "%s is a read-only slot" ...))))
Thanks; I've applied this to Emacs 24.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
Added tag(s) fixed.
Request was from
Lars Magne Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sat, 16 Jul 2011 15:54:04 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 24.1, send any further explanations to
9035 <at> debbugs.gnu.org and Lawrence Mitchell <wence <at> gmx.li>
Request was from
Lars Magne Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sat, 16 Jul 2011 15:54:05 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, 14 Aug 2011 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 308 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.