* bug#21983: emacs-25: cconv-convert makes invalid transformations on `setq' forms.
@ 2015-11-22 18:10 Alan Mackenzie
[not found] ` <mailman.472.1448215747.31583.bug-gnu-emacs@gnu.org>
0 siblings, 1 reply; 2+ messages in thread
From: Alan Mackenzie @ 2015-11-22 18:10 UTC (permalink / raw)
To: 21983
Hello, Emacs.
It is desirable for the byte compiler to detect `setq' forms with an odd
number of arguments.
However, when lexical binding is enabled, this is prevented by
cconv-convert. This converts a `setq' form into several single `setq's,
and crucially, takes the liberty of supplying a nil argument to the last
`setq' should no argument have been present. This is a bug.
Here's a patch which appears to fix the problem:
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index efa9a3d..4a3c273 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -477,17 +477,19 @@ cconv-convert
(while forms
(let* ((sym (pop forms))
(sym-new (or (cdr (assq sym env)) sym))
- (value (cconv-convert (pop forms) env extend)))
+ (value-in-list
+ (and forms
+ (list (cconv-convert (pop forms) env extend)))))
(push (pcase sym-new
- ((pred symbolp) `(setq ,sym-new ,value))
- (`(car-safe ,iexp) `(setcar ,iexp ,value))
+ ((pred symbolp) `(setq ,sym-new ,@value-in-list))
+ (`(car-safe ,iexp) `(setcar ,iexp ,@value-in-list))
;; This "should never happen", but for variables which are
;; mutated+captured+unused, we may end up trying to `setq'
;; on a closed-over variable, so just drop the setq.
(_ ;; (byte-compile-report-error
;; (format "Internal error in cconv of (setq %s ..)"
;; sym-new))
- value))
+ (car value-in-list)))
prognlist)))
(if (cdr prognlist)
`(progn . ,(nreverse prognlist))
Because cconv-convert is written in pcase rather than elisp, I may have
slipped up on some subtlety. Would somebody please check I haven't.
Thanks!
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#21983: emacs-25: cconv-convert makes invalid transformations on `setq' forms.
[not found] ` <mailman.472.1448215747.31583.bug-gnu-emacs@gnu.org>
@ 2015-11-23 14:13 ` Alan Mackenzie
0 siblings, 0 replies; 2+ messages in thread
From: Alan Mackenzie @ 2015-11-23 14:13 UTC (permalink / raw)
To: 21983-done; +Cc: Alan Mackenzie
Fixed in emacs-25 branch.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-23 14:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-22 18:10 bug#21983: emacs-25: cconv-convert makes invalid transformations on `setq' forms Alan Mackenzie
[not found] ` <mailman.472.1448215747.31583.bug-gnu-emacs@gnu.org>
2015-11-23 14:13 ` Alan Mackenzie
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).