unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch to have let and let* test that the arglist is a list
@ 2017-01-18 18:53 Philipp Stephani
  2017-01-18 21:25 ` Alan Mackenzie
  0 siblings, 1 reply; 4+ messages in thread
From: Philipp Stephani @ 2017-01-18 18:53 UTC (permalink / raw)
  To: Emacs developers


[-- Attachment #1.1: Type: text/plain, Size: 113 bytes --]

Hi,

I've attached a small patch for let and let* to make them check for the
type of the argument list.

Philipp

[-- Attachment #1.2: Type: text/html, Size: 186 bytes --]

[-- Attachment #2: 0001-Check-that-variable-lists-are-actually-lists.txt --]
[-- Type: text/plain, Size: 1843 bytes --]

From 84ad5052fd65053a665219897883fdee88a3409c Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Wed, 18 Jan 2017 19:49:58 +0100
Subject: [PATCH] Check that variable lists are actually lists

'let' and 'let*' document that their first argument has to be a list,
but don't check for that; instead, they allow (and silently ignore)
other types.  Introduce an explicit type check.

* src/eval.c (Flet, FletX): Check that the variable list is indeed a
list.
* test/src/eval-tests.el: Add unit tests.
---
 src/eval.c             |  2 ++
 test/src/eval-tests.el | 10 ++++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/eval.c b/src/eval.c
index 1f8d409932..c05c8d8f8d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -857,6 +857,7 @@ usage: (let* VARLIST BODY...)  */)
   lexenv = Vinternal_interpreter_environment;
 
   varlist = XCAR (args);
+  CHECK_LIST (varlist);
   while (CONSP (varlist))
     {
       QUIT;
@@ -917,6 +918,7 @@ usage: (let VARLIST BODY...)  */)
   USE_SAFE_ALLOCA;
 
   varlist = XCAR (args);
+  CHECK_LIST (varlist);
 
   /* Make space to hold the values to give the bound variables.  */
   elt = Flength (varlist);
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index a1fe8ccd7d..95655eac82 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -47,4 +47,14 @@
     (let ((byte-compile-debug t))
       (should-error (eval `(byte-compile (lambda ,args)) t)))))
 
+
+(dolist (form '(let let*))
+  (dolist (arg '(1 "a" [a]))
+    (eval
+     `(ert-deftest ,(intern (format "eval-tests--%s--%s" form (type-of arg))) ()
+        ,(format "Check that the first argument of `%s' cannot be a %s"
+                 form (type-of arg))
+        (should-error (,form ,arg) :type 'wrong-type-argument))
+     t)))
+
 ;;; eval-tests.el ends here
-- 
2.11.0.483.g087da7b7c-goog


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

* Re: Patch to have let and let* test that the arglist is a list
  2017-01-18 18:53 Patch to have let and let* test that the arglist is a list Philipp Stephani
@ 2017-01-18 21:25 ` Alan Mackenzie
  2017-01-19  3:52   ` John Wiegley
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2017-01-18 21:25 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: Emacs developers

On Wed, Jan 18, 2017 at 06:53:22PM +0000, Philipp Stephani wrote:
> Hi,

> I've attached a small patch for let and let* to make them check for the
> type of the argument list.

It's worth noting that the byte compiler already checks this.

I think the patch is a good idea.

> Philipp

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: Patch to have let and let* test that the arglist is a list
  2017-01-18 21:25 ` Alan Mackenzie
@ 2017-01-19  3:52   ` John Wiegley
  2017-01-19 16:24     ` Philipp Stephani
  0 siblings, 1 reply; 4+ messages in thread
From: John Wiegley @ 2017-01-19  3:52 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Philipp Stephani, Emacs developers

>>>>> "AM" == Alan Mackenzie <acm@muc.de> writes:

>> I've attached a small patch for let and let* to make them check for the
>> type of the argument list.

AM> I think the patch is a good idea.

Agreed.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

* Re: Patch to have let and let* test that the arglist is a list
  2017-01-19  3:52   ` John Wiegley
@ 2017-01-19 16:24     ` Philipp Stephani
  0 siblings, 0 replies; 4+ messages in thread
From: Philipp Stephani @ 2017-01-19 16:24 UTC (permalink / raw)
  To: Alan Mackenzie, Emacs developers

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

John Wiegley <jwiegley@gmail.com> schrieb am Do., 19. Jan. 2017 um
04:53 Uhr:

> >>>>> "AM" == Alan Mackenzie <acm@muc.de> writes:
>
> >> I've attached a small patch for let and let* to make them check for the
> >> type of the argument list.
>
> AM> I think the patch is a good idea.
>
> Agreed.
>
>
Thanks, pushed to master.

[-- Attachment #2: Type: text/html, Size: 905 bytes --]

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

end of thread, other threads:[~2017-01-19 16:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-18 18:53 Patch to have let and let* test that the arglist is a list Philipp Stephani
2017-01-18 21:25 ` Alan Mackenzie
2017-01-19  3:52   ` John Wiegley
2017-01-19 16:24     ` Philipp Stephani

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).