summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2021-10-04 16:34:55 +0530
committerArun Isaac2021-10-04 16:34:55 +0530
commitffb909bf27158e10a032dc4df0d0c54bba37889b (patch)
tree880734d0c17fa383b046e008880e9a2b3d207077
parent2d9df0fc90e96a39ace2446341cf8cbf7be33c29 (diff)
downloadccwl-ffb909bf27158e10a032dc4df0d0c54bba37889b.tar.gz
ccwl-ffb909bf27158e10a032dc4df0d0c54bba37889b.tar.lz
ccwl-ffb909bf27158e10a032dc4df0d0c54bba37889b.zip
ccwl: Error out on invalid keywords to lambda**.
* ccwl/utils.scm (lambda**): Error out on invalid keywords (that is, keywords other than #:key, #:key* and #:allow-other-keys). * tests/utils.scm ("lambda** should error out on unrecognized keywords in arguments"): New test.
-rw-r--r--ccwl/utils.scm8
-rw-r--r--tests/utils.scm5
2 files changed, 13 insertions, 0 deletions
diff --git a/ccwl/utils.scm b/ccwl/utils.scm
index d6ca964..4be2fe7 100644
--- a/ccwl/utils.scm
+++ b/ccwl/utils.scm
@@ -155,6 +155,14 @@ while that for n-ary arguments is the empty list. For example,
(list)))
(nary-arguments (or (plist-ref grouped-rest #:key*)
(list))))
+ (for-each (lambda (keyword)
+ (unless (memq keyword (list #:key #:key* #:allow-other-keys))
+ (scm-error 'misc-error
+ #f
+ "Invalid keyword `~S' in `~S'"
+ (list keyword (syntax->datum args-spec))
+ #f)))
+ (filter keyword? args-spec))
#`(apply (lambda* #,(append positionals
(cons #:key unary-arguments)
(map (lambda (x)
diff --git a/tests/utils.scm b/tests/utils.scm
index 07e02f8..a123719 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -80,6 +80,11 @@
((lambda** (#:key* foo)
foo)))
+(test-error "lambda** should error out on unrecognized keywords in arguments" #t
+ (macroexpand
+ '(lambda** (#:key foo #:foo bar)
+ foo)))
+
(test-assert "syntax-lambda**"
(equal? (list #'1 #'2 #'123 (list #'1 #'2 #'3))
((syntax-lambda** (a b #:key foo #:key* bar)