Have `procedure-arguments' always return the `allow-other-keys?' pair.
authorLudovic Courtès <ludo@gnu.org>
Sun, 1 Jul 2012 15:32:03 +0000 (17:32 +0200)
committerLudovic Courtès <ludo@gnu.org>
Mon, 2 Jul 2012 13:08:25 +0000 (15:08 +0200)
Fixes <http://bugs.gnu.org/10938>.
Based on a patch by Stefan Israelsson Tampe <stefan.itampe@gmail.com>.

* module/ice-9/session.scm (procedure-arguments): When the 'arglist
  property is available, emit the `allow-other-keys?' pair.  Use
  `match-lambda'.

* test-suite/tests/session.test ("procedure-arguments")["aok? is
  preserved"]: New test.

module/ice-9/session.scm
test-suite/tests/session.test

index fbb03d2..0eeed86 100644 (file)
@@ -1,4 +1,5 @@
-;;;;   Copyright (C) 1997, 2000, 2001, 2003, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
+;;;; Copyright (C) 1997, 2000, 2001, 2003, 2006, 2009, 2010, 2011,
+;;;;    2012 Free Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -20,6 +21,7 @@
   #:use-module (ice-9 documentation)
   #:use-module (ice-9 regex)
   #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 match)
   #:export (help
             add-value-help-handler! remove-value-help-handler!
             add-name-help-handler! remove-name-help-handler!
@@ -504,14 +506,16 @@ It is an image under the mapping EXTRACT."
 if the information cannot be obtained.
 
 The alist keys that are currently defined are `required', `optional',
-`keyword', and `rest'."
+`keyword', `allow-other-keys?', and `rest'."
   (cond
    ((procedure-property proc 'arglist)
-    => (lambda (arglist)
-         `((required . ,(car arglist))
-           (optional . ,(cadr arglist))
-           (keyword . ,(caddr arglist))
-           (rest . ,(car (cddddr arglist))))))
+    => (match-lambda
+        ((req opt keyword aok? rest)
+         `((required . ,req)
+           (optional . ,opt)
+           (keyword . ,keyword)
+           (allow-other-keys? . ,aok?)
+           (rest . ,rest)))))
    ((procedure-source proc)
     => cadr)
    (((@ (system vm program) program?) proc)
index 4d1bb6f..242ecf9 100644 (file)
     (lambda* (a b #:optional o p #:key k l #:rest r) #f)
     ((required . (a b)) (optional . (o p))
      (keyword . ((#:k . 5) (#:l . 6))) (allow-other-keys? . #f)
-     (rest . k))))
+     (rest . k)))
+
+  (pass-if "aok? is preserved"
+    ;; See <http://bugs.gnu.org/10938>.
+    (let* ((proc (compile '(lambda (a b) #f) #:to 'value))
+           (args (procedure-arguments proc)))
+      (set-procedure-property! proc 'arglist (map cdr args))
+      (equal? args (procedure-arguments proc)))))
 
 ;;; Local Variables:
 ;;; eval: (put 'pass-if-valid-arguments 'scheme-indent-function 1)