~ chicken-core (chicken-5) e87a7e808903303f71e82a3d069e3fb0ff2ae860
commit e87a7e808903303f71e82a3d069e3fb0ff2ae860 Author: Jim Ursetto <zbigniewsz@gmail.com> AuthorDate: Mon Apr 23 11:16:52 2012 -0500 Commit: Peter Bex <peter.bex@xs4all.nl> CommitDate: Mon Apr 23 20:00:02 2012 +0200 Prevent #!key from occurring twice in DSSSL arg lists; add tests for this and other misc DSSSL syntax Signed-off-by: Peter Bex <peter.bex@xs4all.nl> diff --git a/expand.scm b/expand.scm index e523a0cf..1e137b98 100644 --- a/expand.scm +++ b/expand.scm @@ -407,7 +407,7 @@ (err "`#!rest' argument marker in wrong context") ) ] [(#!key) (if (not rvar) (set! rvar (macro-alias 'tmp se))) - (if (fx<= mode 3) + (if (fx<= mode 2) (loop 3 req opt '() r) (err "`#!key' argument marker in wrong context") ) ] [else diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm index 17d533d9..c5f038cd 100644 --- a/tests/syntax-tests.scm +++ b/tests/syntax-tests.scm @@ -792,6 +792,30 @@ (assert (equal? '(3 4 5 i: 6 j: 7 (i: 6 j: 7 8)) (test-optional-key&rest 3 4 5 i: 6 j: 7 8))) +;;; Miscellaneous DSSSL tests + +;; DSSSL annotations may each appear only once +(f (eval '(lambda (x #!optional o1 #!optional o2) 'foo))) +(f (eval '(lambda (x #!rest r1 #!rest r1) 'foo))) +(f (eval '(lambda (x #!key k1 #!key k2) 'foo))) + +;; DSSSL annotations must occur in order (optional, rest, key) +(f (eval '(lambda (x #!rest r1 #!optional o1) 'foo))) +(f (eval '(lambda (x #!key k1 #!optional o1) 'foo))) +(f (eval '(lambda (x #!key r1 #!rest k1) 'foo))) + +;; #!rest limited to 1 arg +(f (eval '(lambda (x #!rest r1 r2) 'foo))) + +;; list arguments invalid for required and rest parameters +(f (eval '(lambda ((x 0) #!rest r1) 'foo))) +(f (eval '(lambda (x #!rest (r1 0)) 'foo))) + +;; Dotted list syntax can be mixed in +(t '(1 2 3 4 (5 6)) + ((lambda (x y #!optional o1 o2 . r) (list x y o1 o2 r)) + 1 2 3 4 5 6)) + ;;; import not seen, if explicitly exported and renamed: (module rfoo (rbar rbaz)Trap