Changed order of imports in require/typed to order written.
Closes PR11193.
This commit is contained in:
parent
76a1112df0
commit
b5e4515752
17
collects/tests/typed-scheme/succeed/pr11193.rkt
Normal file
17
collects/tests/typed-scheme/succeed/pr11193.rkt
Normal 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)
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user