* bug#9035: 24.0.50; byte-compiler warnings with defstruct and lexical-binding
@ 2011-07-09 13:10 Lawrence Mitchell
2011-07-16 15:53 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: Lawrence Mitchell @ 2011-07-09 13:10 UTC (permalink / raw)
To: 9035
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-16 15:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-09 13:10 bug#9035: 24.0.50; byte-compiler warnings with defstruct and lexical-binding Lawrence Mitchell
2011-07-16 15:53 ` Lars Magne Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.