From: Nathan Trapuzzano <nbtrap@nbtrap.com>
To: Leo Liu <sdl.web@gmail.com>
Cc: 15786@debbugs.gnu.org
Subject: bug#15786: 24.3; No warning on mal-formed let form when lexical-binding
Date: Sat, 02 Nov 2013 10:14:35 -0400 [thread overview]
Message-ID: <874n7uq4ac.fsf@nbtrap.com> (raw)
In-Reply-To: <m1ob63ljtr.fsf@gmail.com> (Leo Liu's message of "Sat, 02 Nov 2013 08:37:52 +0800")
[-- Attachment #1: Type: text/plain, Size: 929 bytes --]
Leo Liu <sdl.web@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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: cconv.el.patch --]
[-- Type: text/x-diff, Size: 1379 bytes --]
From 1cce762e1586ce9faa7fc41712973e22c1ea723c Mon Sep 17 00:00:00 2001
From: Nathan Trapuzzano <nbtrap@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
next prev parent reply other threads:[~2013-11-02 14:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-02 0:37 bug#15786: 24.3; No warning on mal-formed let form when lexical-binding Leo Liu
2013-11-02 14:14 ` Nathan Trapuzzano [this message]
2013-11-02 14:32 ` Nathan Trapuzzano
2013-11-02 15:26 ` Nathan Trapuzzano
2013-11-04 19:48 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874n7uq4ac.fsf@nbtrap.com \
--to=nbtrap@nbtrap.com \
--cc=15786@debbugs.gnu.org \
--cc=sdl.web@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).