From 3d5fcaa355a65261819748c687a73c4044986538 Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Mon, 29 Sep 2014 22:38:16 -0400 Subject: [PATCH] move pattern-expander contracts to outer modules, trim exports This avoids mysterious errors later in the build process related to TR and static-contracts. I don't see how the pattern-expander code could possibly cause the errors that occur, but this commit fixes them. --- racket/collects/syntax/parse.rkt | 16 +++++++++- racket/collects/syntax/parse/pre.rkt | 6 ++-- .../parse/private/pattern-expander-prop.rkt | 16 +--------- .../syntax/parse/private/pattern-expander.rkt | 29 ++++--------------- 4 files changed, 24 insertions(+), 43 deletions(-) diff --git a/racket/collects/syntax/parse.rkt b/racket/collects/syntax/parse.rkt index 911b5472c5..7e920c2a1e 100644 --- a/racket/collects/syntax/parse.rkt +++ b/racket/collects/syntax/parse.rkt @@ -1,5 +1,6 @@ #lang racket/base -(require racket/contract/base +(require (for-syntax racket/base) + racket/contract/base "parse/pre.rkt" "parse/experimental/provide.rkt" "parse/experimental/contract.rkt") @@ -8,3 +9,16 @@ expr/c) (provide-syntax-class/contract [static (syntax-class/c [(-> any/c any/c) (or/c string? symbol? #f)])]) + +(begin-for-syntax + (require racket/contract/base + "parse/private/pattern-expander-prop.rkt" + "parse/private/pattern-expander.rkt") + (provide pattern-expander? + (contract-out + [pattern-expander + (-> (-> syntax? syntax?) pattern-expander?)] + [prop:pattern-expander + (struct-type-property/c (-> pattern-expander? (-> syntax? syntax?)))] + [syntax-local-syntax-parse-pattern-introduce + (-> syntax? syntax?)]))) diff --git a/racket/collects/syntax/parse/pre.rkt b/racket/collects/syntax/parse/pre.rkt index 1192170255..b9f801ed60 100644 --- a/racket/collects/syntax/parse/pre.rkt +++ b/racket/collects/syntax/parse/pre.rkt @@ -1,12 +1,10 @@ #lang racket/base (require "private/sc.rkt" "private/litconv.rkt" - "private/lib.rkt" - (for-syntax "private/pattern-expander.rkt")) + "private/lib.rkt") (provide (except-out (all-from-out "private/sc.rkt") define-integrable-syntax-class syntax-parser/template parser/rhs) (all-from-out "private/litconv.rkt") - (all-from-out "private/lib.rkt") - (for-syntax (all-from-out "private/pattern-expander.rkt"))) + (all-from-out "private/lib.rkt")) diff --git a/racket/collects/syntax/parse/private/pattern-expander-prop.rkt b/racket/collects/syntax/parse/private/pattern-expander-prop.rkt index 66e0e68e4d..afb4ab938f 100644 --- a/racket/collects/syntax/parse/private/pattern-expander-prop.rkt +++ b/racket/collects/syntax/parse/private/pattern-expander-prop.rkt @@ -1,6 +1,5 @@ #lang racket/base - -(require racket/contract/base) +(provide (all-defined-out)) (define-values (prop:pattern-expander pattern-expander? get-proc-getter) (make-struct-type-property 'pattern-expander)) @@ -16,16 +15,3 @@ (define (syntax-local-syntax-parse-pattern-introduce stx) ((current-syntax-parse-pattern-introducer) stx)) - -(provide (contract-out - [prop:pattern-expander - (struct-type-property/c (-> pattern-expander? (-> syntax? syntax?)))] - [pattern-expander? - (-> any/c boolean?)] - [pattern-expander-proc - (-> pattern-expander? (-> syntax? syntax?))] - [current-syntax-parse-pattern-introducer - (parameter/c (-> syntax? syntax?))] - [syntax-local-syntax-parse-pattern-introduce - (-> syntax? syntax?)] - )) diff --git a/racket/collects/syntax/parse/private/pattern-expander.rkt b/racket/collects/syntax/parse/private/pattern-expander.rkt index d43e1eb3d4..9b4bd8d505 100644 --- a/racket/collects/syntax/parse/private/pattern-expander.rkt +++ b/racket/collects/syntax/parse/private/pattern-expander.rkt @@ -1,25 +1,8 @@ #lang racket/base +(require (only-in "pattern-expander-prop.rkt" prop:pattern-expander)) +(provide pattern-expander) -(provide prop:pattern-expander - pattern-expander - pattern-expander? - pattern-expander-proc - syntax-local-syntax-parse-pattern-introduce - ) - -(require "pattern-expander-prop.rkt") - -(module pattern-expander-struct racket/base - (require racket/contract/base) - - (require (only-in "pattern-expander-prop.rkt" prop:pattern-expander)) - - (struct pattern-expander (proc) #:transparent - #:property prop:pattern-expander - (λ (this) (pattern-expander-proc this))) ; needs to be wrapped in (λ (this) (_ this)) - - (provide (contract-out - [struct pattern-expander ([proc (-> syntax? syntax?)])] - ))) - -(require (only-in 'pattern-expander-struct pattern-expander)) +(struct pattern-expander (proc) #:transparent + #:omit-define-syntaxes ;; don't give indirect access to proc via match + #:property prop:pattern-expander + (λ (this) (pattern-expander-proc this))) ; needs to be wrapped in (λ (this) (_ this))