allow empty splicing-syntax-parameterize body in a defn context (PR 10311)
svn: r15251
This commit is contained in:
parent
be229c2f5e
commit
7f019819e0
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
(#%provide (for-syntax do-syntax-parameterize))
|
(#%provide (for-syntax do-syntax-parameterize))
|
||||||
|
|
||||||
(define-for-syntax (do-syntax-parameterize stx let-syntaxes-id)
|
(define-for-syntax (do-syntax-parameterize stx let-syntaxes-id empty-body-ok?)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ ([id val] ...) body0 body ...)
|
[(_ ([id val] ...) body ...)
|
||||||
(let ([ids (syntax->list #'(id ...))])
|
(let ([ids (syntax->list #'(id ...))])
|
||||||
(with-syntax ([(gen-id ...)
|
(with-syntax ([(gen-id ...)
|
||||||
(map (lambda (id)
|
(map (lambda (id)
|
||||||
|
@ -43,7 +43,13 @@
|
||||||
"duplicate binding"
|
"duplicate binding"
|
||||||
stx
|
stx
|
||||||
dup)))
|
dup)))
|
||||||
|
(unless empty-body-ok?
|
||||||
|
(when (null? (syntax-e #'(body ...)))
|
||||||
|
(raise-syntax-error
|
||||||
|
#f
|
||||||
|
"missing body expression(s)"
|
||||||
|
stx)))
|
||||||
(with-syntax ([let-syntaxes let-syntaxes-id])
|
(with-syntax ([let-syntaxes let-syntaxes-id])
|
||||||
(syntax/loc stx
|
(syntax/loc stx
|
||||||
(let-syntaxes ([(gen-id) (convert-renamer val)] ...)
|
(let-syntaxes ([(gen-id) (convert-renamer val)] ...)
|
||||||
body0 body ...)))))])))
|
body ...)))))])))
|
||||||
|
|
|
@ -169,9 +169,9 @@
|
||||||
(define-syntax (splicing-syntax-parameterize stx)
|
(define-syntax (splicing-syntax-parameterize stx)
|
||||||
(if (eq? 'expression (syntax-local-context))
|
(if (eq? 'expression (syntax-local-context))
|
||||||
;; Splicing is no help in an expression context:
|
;; Splicing is no help in an expression context:
|
||||||
(do-syntax-parameterize stx #'let-syntaxes)
|
(do-syntax-parameterize stx #'let-syntaxes #f)
|
||||||
;; Let `syntax-parameterize' check syntax, then continue
|
;; Let `syntax-parameterize' check syntax, then continue
|
||||||
(do-syntax-parameterize stx #'ssp-let-syntaxes)))
|
(do-syntax-parameterize stx #'ssp-let-syntaxes #t)))
|
||||||
|
|
||||||
(define-syntax (ssp-let-syntaxes stx)
|
(define-syntax (ssp-let-syntaxes stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
|
|
|
@ -31,4 +31,4 @@
|
||||||
gen-id))))))]))
|
gen-id))))))]))
|
||||||
|
|
||||||
(define-syntax (syntax-parameterize stx)
|
(define-syntax (syntax-parameterize stx)
|
||||||
(do-syntax-parameterize stx #'let-syntaxes)))
|
(do-syntax-parameterize stx #'let-syntaxes #f)))
|
||||||
|
|
|
@ -66,7 +66,8 @@ forms are valid in an internal-definition context. In particular,
|
||||||
@scheme[require] and @scheme[provide] forms cannot appear in the body
|
@scheme[require] and @scheme[provide] forms cannot appear in the body
|
||||||
of @scheme[splicing-syntax-parameterize], even if
|
of @scheme[splicing-syntax-parameterize], even if
|
||||||
@scheme[splicing-syntax-parameterize] is used in a @scheme[module]
|
@scheme[splicing-syntax-parameterize] is used in a @scheme[module]
|
||||||
body.
|
body. In a definition context, the body of
|
||||||
|
@scheme[splicing-syntax-parameterize] can be empty.
|
||||||
|
|
||||||
@examples[
|
@examples[
|
||||||
#:eval splice-eval
|
#:eval splice-eval
|
||||||
|
|
Loading…
Reference in New Issue
Block a user