Changed order of imports in require/typed to order written.

Closes PR11193.
This commit is contained in:
Eric Dobson 2011-06-30 11:23:24 -04:00 committed by Vincent St-Amour
parent 76a1112df0
commit b5e4515752
2 changed files with 30 additions and 6 deletions

View File

@ -0,0 +1,17 @@
#lang racket/load
(module a racket
(define-struct foo (bar baz))
(define f (lambda (x) (+ (foo-bar x) 3)))
(provide [struct-out foo]
f))
(module b typed/racket
(require/typed 'a
[struct foo ([bar : Number] [baz : String])]
[f (foo -> Number)])
(f (foo 3 "4")))
(require 'b)

View File

@ -100,15 +100,22 @@ This file defines two sorts of primitives. All of them are provided into any mod
#:fail-unless (eq? 'opaque (syntax-e #'opaque)) #f
#:with opt #'(#:name-exists)))
(define-syntax-class (clause legacy lib)
#:attributes (spec)
(pattern oc:opaque-clause #:attr spec
#`(require/opaque-type oc.ty oc.pred #,lib . oc.opt))
(pattern (~var strc (struct-clause legacy)) #:attr spec
#`(require-typed-struct strc.nm (strc.body ...) strc.constructor-parts ... #,lib))
(pattern sc:simple-clause #:attr spec
#`(require/typed #:internal sc.nm sc.ty #,lib)))
(define ((r/t-maker legacy) stx)
(syntax-parse stx
[(_ lib:expr (~or sc:simple-clause (~var strc (struct-clause legacy)) oc:opaque-clause) ...)
(unless (< 0 (length (syntax->list #'(sc ... strc ... oc ...))))
[(_ lib:expr (~var c (clause legacy #'lib)) ...)
(unless (< 0 (length (syntax->list #'(c ...))))
(raise-syntax-error #f "at least one specification is required" stx))
#`(begin
(require/opaque-type oc.ty oc.pred lib . oc.opt) ...
(require/typed #:internal sc.nm sc.ty lib) ...
(require-typed-struct strc.nm (strc.body ...) strc.constructor-parts ... lib) ...)]
#`(begin c.spec ...)]
[(_ nm:opt-rename ty lib (~optional [~seq #:struct-maker parent]) ...)
#`(require/typed #:internal nm ty lib #,@(if (attribute parent)
#'(#:struct-maker parent)