Don't allow dot-notation with other meta-keywords
svn: r1139
This commit is contained in:
parent
acfb67ec9b
commit
4130a38299
|
@ -40,8 +40,17 @@
|
|||
;; turns formals into a syntax list
|
||||
(define (formals->list formals)
|
||||
(syntax-case formals ()
|
||||
[(formal ... . rest) ; dot is exactly like #:rest
|
||||
(formals->list #'(formal ... #:rest rest))]
|
||||
[(formal ... . rest)
|
||||
;; dot is exactly like #:rest, but don't allow it with other
|
||||
;; meta-keywords since its meaning is confusing
|
||||
(let* ([formals (syntax->list #'(formal ...))]
|
||||
[kwd (ormap (lambda (s) (and (keyword? (syntax-e* s)) s))
|
||||
formals)])
|
||||
(if kwd
|
||||
(serror #'rest "use #:rest or #:body instead of dot notation"
|
||||
;; (syntax-e* kwd) <- confusing to show this
|
||||
)
|
||||
(append formals (list #'#:rest #'rest))))]
|
||||
[(formal ...) (syntax->list formals)]))
|
||||
;; is an expression simple? (=> evaluating cannot have side effects)
|
||||
(define (simple-expr? expr)
|
||||
|
@ -111,9 +120,9 @@
|
|||
([(only-vars?) (and (pair? only-vars?) (car only-vars?))]
|
||||
[(opts keys0) (values (map process-opt opts) (map process-key keys0))]
|
||||
[(rest body rest-keys all-keys other-keys)
|
||||
(apply values
|
||||
(map (lambda (k) (cond [(assq k rests) => cdr] [else #f]))
|
||||
'(#:rest #:body #:rest-keys #:all-keys #:other-keys)))]
|
||||
(apply values (map (lambda (k)
|
||||
(cond [(assq k rests) => cdr] [else #f]))
|
||||
rest-like-kwds))]
|
||||
[(rest* body* other-keys*)
|
||||
(values (or rest (gensym #'rest))
|
||||
(if (and body (identifier? body)) body (gensym #'body))
|
||||
|
|
|
@ -288,6 +288,7 @@
|
|||
;; test syntax errors
|
||||
(t :st-err: <= (lambda/kw (x #:blah y) 1)
|
||||
:st-err: <= (lambda/kw (x #:rest) 1)
|
||||
:st-err: <= (lambda/kw (x #:key k . r) 1)
|
||||
:st-err: <= (lambda/kw (x #:key k #:key o) 1)
|
||||
:st-err: <= (lambda/kw (x #:key k #:optional o) 1)
|
||||
:st-err: <= (lambda/kw (x #:optional k #:optional o) 1)
|
||||
|
|
Loading…
Reference in New Issue
Block a user