all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#15786: 24.3; No warning on mal-formed let form when lexical-binding
@ 2013-11-02  0:37 Leo Liu
  2013-11-02 14:14 ` Nathan Trapuzzano
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Liu @ 2013-11-02  0:37 UTC (permalink / raw)
  To: 15786

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]

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.


[-- Attachment #2: t.el --]
[-- Type: application/emacs-lisp, Size: 314 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#15786: 24.3; No warning on mal-formed let form when lexical-binding
  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
  2013-11-02 14:32   ` Nathan Trapuzzano
  2013-11-02 15:26   ` Nathan Trapuzzano
  0 siblings, 2 replies; 5+ messages in thread
From: Nathan Trapuzzano @ 2013-11-02 14:14 UTC (permalink / raw)
  To: Leo Liu; +Cc: 15786

[-- 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#15786: 24.3; No warning on mal-formed let form when lexical-binding
  2013-11-02 14:14 ` Nathan Trapuzzano
@ 2013-11-02 14:32   ` Nathan Trapuzzano
  2013-11-02 15:26   ` Nathan Trapuzzano
  1 sibling, 0 replies; 5+ messages in thread
From: Nathan Trapuzzano @ 2013-11-02 14:32 UTC (permalink / raw)
  To: Leo Liu; +Cc: 15786

Nathan Trapuzzano <nbtrap@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.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#15786: 24.3; No warning on mal-formed let form when lexical-binding
  2013-11-02 14:14 ` Nathan Trapuzzano
  2013-11-02 14:32   ` Nathan Trapuzzano
@ 2013-11-02 15:26   ` Nathan Trapuzzano
  2013-11-04 19:48     ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Nathan Trapuzzano @ 2013-11-02 15:26 UTC (permalink / raw)
  To: Leo Liu; +Cc: 15786

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

Nathan Trapuzzano <nbtrap@nbtrap.com> writes:

> Patch attached.

Sorry, that patch messed up with (let ((var-with-no-value-form)) ...).

Correct patch attached here.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: cconv.el.patch --]
[-- Type: text/x-diff, Size: 1377 bytes --]

From 1cd7356af9caca830f4764205dcbd2f6afe4b6d3 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..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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#15786: 24.3; No warning on mal-formed let form when lexical-binding
  2013-11-02 15:26   ` Nathan Trapuzzano
@ 2013-11-04 19:48     ` Stefan Monnier
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2013-11-04 19:48 UTC (permalink / raw)
  To: Nathan Trapuzzano; +Cc: 15786-done, Leo Liu

> Correct patch attached here.

Thanks, installed,


        Stefan





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-04 19:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2013-11-02 14:32   ` Nathan Trapuzzano
2013-11-02 15:26   ` Nathan Trapuzzano
2013-11-04 19:48     ` Stefan Monnier

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.