This is the mail archive of the
cgen@sourceware.org
mailing list for the CGEN project.
[patch] Fix pmacro handling of default values when passed an empty arg list.
- From: Doug Evans <dje at sebabeach dot org>
- To: cgen at sourceware dot org
- Date: Sat, 26 Apr 2008 11:34:34 -0700
- Subject: [patch] Fix pmacro handling of default values when passed an empty arg list.
Re:
* From: Joern Rennecke <joernr at arc dot com>
* To: cgen at sources dot redhat dot com
* Date: Thu, 18 Jan 2007 15:27:24 +0000
* Subject: bug when eliding arguments with default values?
I have some problem where I thougt an optional argument would be useful
for a macro that usually doesn't take an argument.
The actual code is a bit complex, so here is a stripped down example:
guile> (define-pmacro '(foo (arg1 . 1)) '(bar arg1))
guile> (pmacro-expand '(foo))
[...]
/pmacros.scm:99:3: In procedure error in expression (error (string-append # ":" ...) expr):
./pmacros.scm:99:3: standard input:13:wrong number of arguments to pmacro (foo arg1): ()
ABORT: (misc-error)
Maybe something like this,
2008-04-26 Doug Evans <dje@sebabeach.org>
* pmacros.scm (-pmacro-process-args): Fix handling of default values
when passed an empty arg list.
Index: pmacros.scm
===================================================================
RCS file: /cvs/src/src/cgen/pmacros.scm,v
retrieving revision 1.5
diff -u -p -r1.5 pmacros.scm
--- pmacros.scm 13 Jun 2005 22:28:30 -0000 1.5
+++ pmacros.scm 26 Apr 2008 18:23:07 -0000
@@ -148,7 +148,8 @@
; DEFAULT-VALUES.
(define (-pmacro-process-args arg-spec default-values args)
- (if (and (pair? args) (keyword? (car args)))
+ (if (or (and (pair? args) (keyword? (car args)))
+ (null? args))
(-pmacro-process-keyworded-args arg-spec default-values args)
args)
)