diff options
-rw-r--r-- | ccwl/utils.scm | 8 | ||||
-rw-r--r-- | tests/utils.scm | 5 |
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) |