From 2247ce6266469ee38ef9e2795335b9de24521927 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 22 Jul 2013 12:51:02 -0600 Subject: [PATCH] Make `syntax-procedure-{alias,converted-arguments}-property' cross-phase --- .../scribblings/reference/stx-trans.scrbl | 4 ++-- .../racket-test/tests/racket/syntax.rktl | 21 +++++++++++++++++++ .../collects/racket/private/kw-prop-key.rkt | 9 ++++++++ racket/collects/racket/private/kw.rkt | 5 ++--- .../racket/private/procedure-alias.rkt | 4 ++-- 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 racket/collects/racket/private/kw-prop-key.rkt diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/stx-trans.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/reference/stx-trans.scrbl index e20862a2d7..520933b920 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/reference/stx-trans.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/reference/stx-trans.scrbl @@ -1202,9 +1202,9 @@ first argument.} val?))] )]{ -At expansion time, reports the value of a syntax property that can be +Reports the value of a syntax property that can be attached to an identifier by the expansion of a keyword-application -form during the same expansion time. See @racket[lambda] for more +form. See @racket[lambda] for more information about the property. The property value is normally a pair consisting of the original diff --git a/pkgs/racket-pkgs/racket-test/tests/racket/syntax.rktl b/pkgs/racket-pkgs/racket-test/tests/racket/syntax.rktl index fd968ab19d..f37d808624 100644 --- a/pkgs/racket-pkgs/racket-test/tests/racket/syntax.rktl +++ b/pkgs/racket-pkgs/racket-test/tests/racket/syntax.rktl @@ -1718,6 +1718,27 @@ f-id (eval '(extract f f2 f2 #t)))) + +;; Check that alias & converted-argument information is +;; cross-phase: +(require racket/keyword-transform) +(let ([e (parameterize ([current-namespace (make-base-namespace)]) + (expand '(module m racket/base + (define (f #:x [x 10]) x) + (f #:x 8))))]) + (define (find get) + (let loop ([e e]) + (or (and (syntax? e) + (or (get e) + (loop (syntax-e e)))) + (and (pair? e) + (or (loop (car e)) + (loop (cdr e))))))) + (test #t 'cross-phase-alias + (and (find syntax-procedure-converted-arguments-property) + (find syntax-procedure-alias-property) + #t))) + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Check interaction of marks, `rename-out', and `free-identifier=?' diff --git a/racket/collects/racket/private/kw-prop-key.rkt b/racket/collects/racket/private/kw-prop-key.rkt new file mode 100644 index 0000000000..6cca6da39d --- /dev/null +++ b/racket/collects/racket/private/kw-prop-key.rkt @@ -0,0 +1,9 @@ +(module kw-prop-key '#%kernel + (#%provide (protect alias-of + kw-converted-arguments-variant-of)) + + (#%declare #:cross-phase-persistent) + + (define-values (kw-converted-arguments-variant-of) (gensym "converted-arguments-variant-of")) + (define-values (alias-of) (gensym "alias-of"))) + diff --git a/racket/collects/racket/private/kw.rkt b/racket/collects/racket/private/kw.rkt index dd91cf2c70..44533f4298 100644 --- a/racket/collects/racket/private/kw.rkt +++ b/racket/collects/racket/private/kw.rkt @@ -11,7 +11,8 @@ "name.rkt" "norm-define.rkt" "qqstx.rkt" - "sort.rkt")) + "sort.rkt" + "kw-prop-key.rkt")) (#%provide new-lambda new-λ new-define @@ -974,8 +975,6 @@ (define-for-syntax kw-expander-impl (make-struct-field-accessor kw-expander-ref 1 'impl)) (define-for-syntax kw-expander-proc (make-struct-field-accessor kw-expander-ref 2 'proc)) - (define-for-syntax kw-converted-arguments-variant-of (gensym 'converted-arguments-variant-of)) - (define-for-syntax (syntax-procedure-converted-arguments-property stx) (unless (syntax? stx) (raise-argument-error 'syntax-procedure-converted-arguments "syntax?" stx)) diff --git a/racket/collects/racket/private/procedure-alias.rkt b/racket/collects/racket/private/procedure-alias.rkt index f0d0560a31..b9b0185127 100644 --- a/racket/collects/racket/private/procedure-alias.rkt +++ b/racket/collects/racket/private/procedure-alias.rkt @@ -2,6 +2,7 @@ (#%require "define.rkt" "small-scheme.rkt" "more-scheme.rkt" + "kw-prop-key.rkt" (for-syntax '#%kernel "stx.rkt" "small-scheme.rkt" @@ -11,8 +12,7 @@ "qqstx.rkt" "sort.rkt")) - (#%provide syntax-procedure-alias-property (protect alias-of)) - (define alias-of (gensym 'alias-of)) + (#%provide syntax-procedure-alias-property alias-of) (define (syntax-procedure-alias-property stx) (unless (syntax? stx) (raise-argument-error 'syntax-procedure-alias "syntax?" stx))