diff --git a/collects/errortrace/stacktrace.rkt b/collects/errortrace/stacktrace.rkt index da52e37087..0a616764ef 100644 --- a/collects/errortrace/stacktrace.rkt +++ b/collects/errortrace/stacktrace.rkt @@ -428,7 +428,7 @@ expr (keep-lambda-properties expr - (profile-annotate-lambda name expr expr (syntax body) + (profile-annotate-lambda name expr disarmed-expr (syntax body) phase)))] [(case-lambda clause ...) (with-syntax ([([args . body] ...) diff --git a/collects/lang/private/teach-shared.rkt b/collects/lang/private/teach-shared.rkt index 01508b2f0b..e6a6cfc4d1 100644 --- a/collects/lang/private/teach-shared.rkt +++ b/collects/lang/private/teach-shared.rkt @@ -12,6 +12,8 @@ scheme/base (only-in "teachprims.rkt" [advanced-cons the-cons]))) +(define code-insp (current-code-inspector)) + (define shared/proc (lambda (stx make-check-cdr undefined-expr) (with-syntax ([undefined undefined-expr]) diff --git a/collects/mzlib/private/shared-body.rkt b/collects/mzlib/private/shared-body.rkt index 3cb600a05e..72114c84d5 100644 --- a/collects/mzlib/private/shared-body.rkt +++ b/collects/mzlib/private/shared-body.rkt @@ -1,8 +1,9 @@ ;; Used by ../shared.rkt, and also collects/lang/private/teach.rkt ;; Besides the usual things, this code expects `undefined' and -;; `the-cons' to be bound, and it expects `struct-declaration-info?' -;; from the "struct.rkt" library of the "syntax" collection. +;; `the-cons', to be bound, it expects `struct-declaration-info?' +;; from the "struct.rkt" library of the "syntax" collection, and it +;; expects `code-insp' for-syntax. (syntax-case stx () [(_ ([name expr] ...) body1 body ...) @@ -31,7 +32,7 @@ (kernel-form-identifier-list) names))]) ;; Remove #%app if present... - (syntax-case e (#%plain-app) + (syntax-case (syntax-disarm e code-insp) (#%plain-app) [(#%plain-app a ...) (syntax/loc e (a ...))] [_else e]))) @@ -89,7 +90,8 @@ (if (null? rmv-lst) lst (loop (remove (car rmv-lst) lst) - (cdr rmv-lst)))))]) + (cdr rmv-lst)))))] + [disarm (lambda (stx) (syntax-disarm stx code-insp))]) (with-syntax ([(graph-expr ...) (map (lambda (expr) (let loop ([expr expr]) @@ -107,7 +109,7 @@ ph)) names placeholder-ids ph-used?s)) (loop expr))) - (syntax-case* expr (the-cons mcons append box box-immutable vector vector-immutable) same-special-id? + (syntax-case* (disarm expr) (the-cons mcons append box box-immutable vector vector-immutable) same-special-id? [(the-cons a d) (with-syntax ([a (cons-elem #'a)] [d (cons-elem #'d)]) @@ -194,7 +196,9 @@ [(vector . _) temp-id] [(vector-immutable . _) temp-id] [(make-x . _) - (struct-decl-for (syntax make-x)) + (syntax-case (syntax-disarm expr code-insp) () + [(make-x . _) + (struct-decl-for (syntax make-x))]) temp-id] [else #f])]) (cond @@ -217,7 +221,7 @@ (map (lambda (name expr) (let loop ([name name] [expr expr]) (with-syntax ([name name]) - (syntax-case* expr (the-cons mcons list list* append box box-immutable vector vector-immutable) + (syntax-case* (disarm expr) (the-cons mcons list list* append box box-immutable vector vector-immutable) same-special-id? [(the-cons a d) #`(begin #,(loop #`(car name) #'a) diff --git a/collects/mzlib/shared.rkt b/collects/mzlib/shared.rkt index 05829979ca..e1abe2b8ef 100644 --- a/collects/mzlib/shared.rkt +++ b/collects/mzlib/shared.rkt @@ -9,6 +9,8 @@ (provide shared) +(define-for-syntax code-insp (current-code-inspector)) + (define undefined (letrec ([x x]) x)) (require (only-in scheme/base [cons the-cons])) diff --git a/collects/racket/package.rkt b/collects/racket/package.rkt index 73943bb421..7d7aa423a0 100644 --- a/collects/racket/package.rkt +++ b/collects/racket/package.rkt @@ -102,6 +102,16 @@ orig orig)) +(define-for-syntax code-insp (current-code-inspector)) +(define-for-syntax (disarm* stx) + (cond + [(and (syntax? stx) + (pair? (syntax-e stx))) + (let ([stx (syntax-disarm stx code-insp)]) + (datum->syntax stx (disarm* (syntax-e stx)) stx stx))] + [(pair? stx) (cons (disarm* (car stx)) (disarm* (cdr stx)))] + [else stx])) + (define-for-syntax (do-define-package stx exp-stx) (syntax-case exp-stx () [(_ pack-id mode exports form ...) @@ -155,8 +165,8 @@ [new-bindings (make-bound-identifier-mapping)] [fixup-sub-package (lambda (renamed-exports renamed-defines def-ctxes) (lambda (stx) - (syntax-case* stx (define-syntaxes #%plain-app make-package quote-syntax - list cons #%plain-lambda) + (syntax-case* (disarm* stx) (define-syntaxes #%plain-app make-package quote-syntax + list cons #%plain-lambda) free-transformer-identifier=? [(define-syntaxes (pack-id) (#%plain-app