From 61e890ba153ad013fc5a07c639840047b872a0d4 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Thu, 19 Jul 2012 19:54:02 -0500 Subject: [PATCH] fixes the "not used in definition context" error in define/contract related to PR 12863, but doesn't solve the infinite loop problem (cherry picked from commit 774e254f3caba542841832fcf3003ce88d3befed) --- collects/racket/contract/private/provide.rkt | 4 ++-- collects/racket/contract/region.rkt | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/collects/racket/contract/private/provide.rkt b/collects/racket/contract/private/provide.rkt index b6280bc9ed..29716f90f8 100644 --- a/collects/racket/contract/private/provide.rkt +++ b/collects/racket/contract/private/provide.rkt @@ -799,8 +799,8 @@ (define-syntax (provide/contract stx) (define s-l-c (syntax-local-context)) (case s-l-c - [(module-begin) ;; the case under discussion - #`(begin (define-values () (values)) ;; force us into the 'module' local context + [(module-begin) + #`(begin ;; force us into the 'module' local context #,stx)] [(module) ;; the good case (true-provide/contract stx #f 'provide/contract)] diff --git a/collects/racket/contract/region.rkt b/collects/racket/contract/region.rkt index 15532dfbdb..85dcf52cb0 100644 --- a/collects/racket/contract/region.rkt +++ b/collects/racket/contract/region.rkt @@ -46,10 +46,18 @@ ; ; ; +(define-syntax (define/contract stx) + (define s-l-c (syntax-local-context)) + (case s-l-c + [(module-begin) + #`(begin #,stx)] + [else + (define/contract-expander stx)])) + ;; (define/contract id contract expr) ;; defines `id' with `contract'; initially binding ;; it to the result of `expr'. These variables may not be set!'d. -(define-syntax (define/contract define-stx) +(define-for-syntax (define/contract-expander define-stx) (define-splicing-syntax-class fv-clause #:description "a free variable clause" #:attributes ([var 1] [ctc 1])