unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#25477: 26.0.50; `dolist' macro accepts more than three arguments
@ 2017-01-18 21:35 Philipp Stephani
  2017-03-26 18:56 ` Philipp Stephani
  0 siblings, 1 reply; 3+ messages in thread
From: Philipp Stephani @ 2017-01-18 21:35 UTC (permalink / raw)
  To: 25477


In *scratch*, evaluate

(dolist (a () 1 2 3))

The result is 3, but a `wrong-number-of-arguments' signal should be
raised.


In GNU Emacs 26.0.50.38 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8)
 of 2017-01-18 built on localhost
Repository revision: 5fefaaa8c0696ba4b7b6e1e89267aa10fff88b31
Windowing system distributor 'The X.Org Foundation', version 11.0.11501000
System Description:	Ubuntu 14.04 LTS

Configured using:
 'configure --with-modules --enable-checking
 --enable-check-lisp-object-type 'CFLAGS=-ggdb3 -O0''

Configured features:
XPM JPEG TIFF GIF PNG SOUND GSETTINGS NOTIFY GNUTLS FREETYPE XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message subr-x puny seq byte-opt gv
bytecomp byte-compile cl-extra help-mode cconv cl-loaddefs pcase cl-lib
dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec
password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils time-date mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript case-table epa-hook jka-cmpr-hook help
simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote inotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 97618 6590)
 (symbols 48 20221 1)
 (miscs 40 331 156)
 (strings 32 17992 4049)
 (string-bytes 1 592145)
 (vectors 16 14070)
 (vector-slots 8 471809 3585)
 (floats 8 181 9)
 (intervals 56 207 0)
 (buffers 976 12)
 (heap 1024 33203 1046))

-- 
Google Germany GmbH
Erika-Mann-Straße 33
80636 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle

Diese E-Mail ist vertraulich.  Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen
Sie die E-Mail und alle Anhänge.  Vielen Dank.

This e-mail is confidential.  If you are not the right addressee please do not
forward it, please inform the sender, and please erase this e-mail including
any attachments.  Thanks.





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

* bug#25477: 26.0.50; `dolist' macro accepts more than three arguments
  2017-01-18 21:35 bug#25477: 26.0.50; `dolist' macro accepts more than three arguments Philipp Stephani
@ 2017-03-26 18:56 ` Philipp Stephani
  2017-04-08 15:40   ` Philipp Stephani
  0 siblings, 1 reply; 3+ messages in thread
From: Philipp Stephani @ 2017-03-26 18:56 UTC (permalink / raw)
  To: 25477


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

Philipp Stephani <p.stephani2@gmail.com> schrieb am Mi., 18. Jan. 2017 um
22:37 Uhr:

>
> In *scratch*, evaluate
>
> (dolist (a () 1 2 3))
>
> The result is 3, but a `wrong-number-of-arguments' signal should be
> raised.
>

I've attached a patch.

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

[-- Attachment #2: 0001-Validate-SPEC-of-dolist-cf.-Bug-25477.txt --]
[-- Type: text/plain, Size: 1891 bytes --]

From cb1f8ce80edf1de7a1f9b886308a688a2ab6dcbf Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Sun, 26 Mar 2017 20:53:43 +0200
Subject: [PATCH] Validate SPEC of `dolist', cf. Bug#25477.

* lisp/subr.el (dolist): Test type and length of SPEC.
* test/lisp/subr-tests.el (subr-tests--dolist--wrong-number-of-args):
Add unit test.
---
 lisp/subr.el            |  4 ++++
 test/lisp/subr-tests.el | 10 ++++++++++
 2 files changed, 14 insertions(+)

diff --git a/lisp/subr.el b/lisp/subr.el
index 6b0403890c..65d1b9b482 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -190,6 +190,10 @@ dolist
 
 \(fn (VAR LIST [RESULT]) BODY...)"
   (declare (indent 1) (debug ((symbolp form &optional form) body)))
+  (unless (consp spec)
+    (signal 'wrong-type-argument (list 'consp spec)))
+  (unless (<= 2 (length spec) 3)
+    (signal 'wrong-number-of-arguments (list '(2 . 3) (length spec))))
   ;; It would be cleaner to create an uninterned symbol,
   ;; but that uses a lot more space when many functions in many files
   ;; use dolist.
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index a3b08e9697..0d243cc5d8 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -281,5 +281,15 @@ subr-test--frames-1
   (should (equal (string-match-p "\\`[[:blank:]]\\'" "\u3000") 0))
   (should-not (string-match-p "\\`[[:blank:]]\\'" "\N{LINE SEPARATOR}")))
 
+(ert-deftest subr-tests--dolist--wrong-number-of-args ()
+  "Test that `dolist' doesn't accept wrong types or length of SPEC,
+cf. Bug#25477."
+  (should-error (eval '(dolist (a)))
+                :type 'wrong-number-of-arguments)
+  (should-error (eval '(dolist (a () 'result 'invalid)) t)
+                :type 'wrong-number-of-arguments)
+  (should-error (eval '(dolist "foo") t)
+                :type 'wrong-type-argument))
+
 (provide 'subr-tests)
 ;;; subr-tests.el ends here
-- 
2.12.2


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

* bug#25477: 26.0.50; `dolist' macro accepts more than three arguments
  2017-03-26 18:56 ` Philipp Stephani
@ 2017-04-08 15:40   ` Philipp Stephani
  0 siblings, 0 replies; 3+ messages in thread
From: Philipp Stephani @ 2017-04-08 15:40 UTC (permalink / raw)
  To: 25477-done

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

Philipp Stephani <p.stephani2@gmail.com> schrieb am So., 26. März 2017 um
20:56 Uhr:

> Philipp Stephani <p.stephani2@gmail.com> schrieb am Mi., 18. Jan. 2017 um
> 22:37 Uhr:
>
>
> In *scratch*, evaluate
>
> (dolist (a () 1 2 3))
>
> The result is 3, but a `wrong-number-of-arguments' signal should be
> raised.
>
>
> I've attached a patch.
>

Pushed as 98bfac68b9.

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

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

end of thread, other threads:[~2017-04-08 15:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-18 21:35 bug#25477: 26.0.50; `dolist' macro accepts more than three arguments Philipp Stephani
2017-03-26 18:56 ` Philipp Stephani
2017-04-08 15:40   ` 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).