GNU bug report logs -
#15786
24.3; No warning on mal-formed let form when lexical-binding
Previous Next
Reported by: Leo Liu <sdl.web <at> gmail.com>
Date: Sat, 2 Nov 2013 00:39:02 UTC
Severity: normal
Found in version 24.3
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
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 15786 in the body.
You can then email your comments to 15786 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org
:
bug#15786
; Package
emacs
.
(Sat, 02 Nov 2013 00:39:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Leo Liu <sdl.web <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org
.
(Sat, 02 Nov 2013 00:39:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Due to a typo in my code, I got a bug report on ggtags
https://github.com/leoliu/ggtags/issues/17. I was fooled by the elisp
compiler which warns mal-formed let forms without lexical-binding.
To reproduce
1. Download the file in the attachment
2. byte-compile it
3. remove the first line and byte-compile it
step 2 produces no warnings while step 3 does.
[t.el (application/emacs-lisp, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15786
; Package
emacs
.
(Sat, 02 Nov 2013 14:15:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 15786 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Leo Liu <sdl.web <at> gmail.com> writes:
> Due to a typo in my code, I got a bug report on ggtags
> https://github.com/leoliu/ggtags/issues/17. I was fooled by the elisp
> compiler which warns mal-formed let forms without lexical-binding.
>
> To reproduce
> 1. Download the file in the attachment
> 2. byte-compile it
> 3. remove the first line and byte-compile it
>
> step 2 produces no warnings while step 3 does.
Under lexical binding, the malformed `let' is correctly reformed in
`cconv-convert' before it gets passed to the optimizer. In other words,
it's assumed to be properly formed. This looks like a bug.
On first thought, it seems that cconv-convert should check for proper
form and signal an _error_ if the check fails. On the other hand, this
would be inconsistent with what happens under dynamic binding. (On that
note, under dynamic binding, why is this considered a warning and not an
error?)
Patch attached.
[cconv.el.patch (text/x-diff, inline)]
From 1cce762e1586ce9faa7fc41712973e22c1ea723c Mon Sep 17 00:00:00 2001
From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Date: Sat, 2 Nov 2013 10:12:35 -0400
Subject: [PATCH] Assert proper form of let binding during byte compilation
under lexical binding.
---
lisp/emacs-lisp/cconv.el | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index f24e503..6d87521 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -289,12 +289,14 @@ places where they originally did not directly appear."
(dolist (binder binders)
(let* ((value nil)
- (var (if (not (consp binder))
- (prog1 binder (setq binder (list binder)))
- (setq value (cadr binder))
- (car binder)))
- (new-val
- (cond
+ (var (if (not (consp binder))
+ (prog1 binder (setq binder (list binder)))
+ (cl-assert (= (length (cdr binder)) 1) nil
+ "malformed let binding: `%s'" (prin1-to-string binder))
+ (setq value (cadr binder))
+ (car binder)))
+ (new-val
+ (cond
;; Check if var is a candidate for lambda lifting.
((and (member (cons binder form) cconv-lambda-candidates)
(progn
--
1.8.4.2
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15786
; Package
emacs
.
(Sat, 02 Nov 2013 14:33:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 15786 <at> debbugs.gnu.org (full text, mbox):
Nathan Trapuzzano <nbtrap <at> nbtrap.com> writes:
> (On that note, under dynamic binding, why is this considered a warning
> and not an error?)
By the way, this is an error when interpreted.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#15786
; Package
emacs
.
(Sat, 02 Nov 2013 15:28:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 15786 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Nathan Trapuzzano <nbtrap <at> nbtrap.com> writes:
> Patch attached.
Sorry, that patch messed up with (let ((var-with-no-value-form)) ...).
Correct patch attached here.
[cconv.el.patch (text/x-diff, inline)]
From 1cd7356af9caca830f4764205dcbd2f6afe4b6d3 Mon Sep 17 00:00:00 2001
From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Date: Sat, 2 Nov 2013 10:12:35 -0400
Subject: [PATCH] Assert proper form of let binding during byte compilation
under lexical binding.
---
lisp/emacs-lisp/cconv.el | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index f24e503..3fc2fc4 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -289,12 +289,14 @@ places where they originally did not directly appear."
(dolist (binder binders)
(let* ((value nil)
- (var (if (not (consp binder))
- (prog1 binder (setq binder (list binder)))
- (setq value (cadr binder))
- (car binder)))
- (new-val
- (cond
+ (var (if (not (consp binder))
+ (prog1 binder (setq binder (list binder)))
+ (cl-assert (null (cdr (cdr binder))) nil
+ "malformed let binding: `%s'" (prin1-to-string binder))
+ (setq value (cadr binder))
+ (car binder)))
+ (new-val
+ (cond
;; Check if var is a candidate for lambda lifting.
((and (member (cons binder form) cconv-lambda-candidates)
(progn
--
1.8.4.2
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Mon, 04 Nov 2013 19:50:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Leo Liu <sdl.web <at> gmail.com>
:
bug acknowledged by developer.
(Mon, 04 Nov 2013 19:50:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 15786-done <at> debbugs.gnu.org (full text, mbox):
> Correct patch attached here.
Thanks, installed,
Stefan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 03 Dec 2013 12:24:04 GMT)
Full text and
rfc822 format available.
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.