|
54 | 54 | (let ([typ (if maker?
|
55 | 55 | ((map fld-t (Struct-flds (lookup-type-name (Name-id typ)))) #f . t:->* . typ)
|
56 | 56 | typ)])
|
57 |
| - (with-syntax ([cnt (type->contract |
58 |
| - typ |
59 |
| - ;; this is for a `require/typed', so the value is not from the typed side |
60 |
| - #:typed-side #f |
61 |
| - #:kind kind |
62 |
| - (lambda () (tc-error/stx prop "Type ~a could not be converted to a contract." typ)))]) |
63 |
| - (quasisyntax/loc stx (define-values (n) (recursive-contract cnt #,(contract-kind->keyword kind))))))] |
64 |
| - [_ (int-err "should never happen - not a define-values: ~a" (syntax->datum stx))])) |
| 57 | + (with-syntax ([cnt (type->contract |
| 58 | + typ |
| 59 | + ;; this is for a `require/typed', so the value is not from the typed side |
| 60 | + #:typed-side #f |
| 61 | + #:kind kind |
| 62 | + (λ () |
| 63 | + (tc-error/stx |
| 64 | + prop |
| 65 | + "Type ~a could not be converted to a contract." |
| 66 | + typ)))]) |
| 67 | + (quasisyntax/loc |
| 68 | + stx |
| 69 | + (define-values (n) |
| 70 | + (recursive-contract |
| 71 | + cnt |
| 72 | + #,(contract-kind->keyword kind))))))] |
| 73 | + [_ (int-err "should never happen - not a define-values: ~a" |
| 74 | + (syntax->datum stx))])) |
65 | 75 |
|
66 | 76 | (define (change-contract-fixups forms)
|
67 | 77 | (map (lambda (e)
|
|
89 | 99 | (for/fold ((acc i)) ((v args))
|
90 | 100 | (contract-kind-max2 v acc)))
|
91 | 101 |
|
92 |
| - |
93 | 102 | (define (contract-kind-min i . args)
|
94 | 103 | (define (contract-kind-min2 x y)
|
95 | 104 | (cond
|
|
106 | 115 | (string->keyword (symbol->string sym)))
|
107 | 116 |
|
108 | 117 | (define (type->contract ty fail #:out [out? #f] #:typed-side [from-typed? #t] #:kind [kind 'impersonator])
|
109 |
| - (define vars (make-parameter '())) |
| 118 | + (define vars (make-parameter '())) |
110 | 119 | (define current-contract-kind (make-parameter flat-sym))
|
111 | 120 | (define (increase-current-contract-kind! kind)
|
112 | 121 | (current-contract-kind (contract-kind-max (current-contract-kind) kind)))
|
|
138 | 147 | [(and
|
139 | 148 | (> (length arrs) 1)
|
140 | 149 | ;; Keyword args, range and rest specs all the same.
|
141 |
| - (let ([xs (map (match-lambda [(arr: _ rng rest-spec _ kws) (list rng rest-spec kws)]) arrs)]) |
| 150 | + (let ([xs (map (match-lambda [(arr: _ rng rest-spec _ kws) |
| 151 | + (list rng rest-spec kws)]) |
| 152 | + arrs)]) |
142 | 153 | (foldl equal? (first xs) (rest xs)))
|
143 | 154 | ;; Positionals are monotonically increasing.
|
144 | 155 | (let-values ([(_ ok?)
|
|
338 | 349 | (match-let ([(Mu-name: n-nm _) ty])
|
339 | 350 | (with-syntax ([(n*) (generate-temporaries (list n-nm))])
|
340 | 351 | (parameterize ([vars (cons (list n #'n*) (vars))]
|
341 |
| - [current-contract-kind (contract-kind-min kind chaperone-sym)]) |
| 352 | + [current-contract-kind |
| 353 | + (contract-kind-min kind chaperone-sym)]) |
342 | 354 | (define ctc (t->c b))
|
343 | 355 | #`(letrec ([n* (recursive-contract
|
344 | 356 | #,ctc
|
345 |
| - #,(contract-kind->keyword (current-contract-kind)))]) |
| 357 | + #,(contract-kind->keyword |
| 358 | + (current-contract-kind)))]) |
346 | 359 | n*))))]
|
347 | 360 | [(Value: #f) #'false/c]
|
348 | 361 | [(Instance: (? Mu? t))
|
|
389 | 402 | #`(syntax/c #,(t->c t #:kind flat-sym))]
|
390 | 403 | [(Value: v) #`(flat-named-contract #,(format "~a" v) (lambda (x) (equal? x '#,v)))]
|
391 | 404 | ;; TODO Is this sound?
|
392 |
| - [(Param: in out) #`(parameter/c #,(t->c out))] |
| 405 | + [(Param: in out) |
| 406 | + (set-impersonator!) |
| 407 | + #`(parameter/c #,(t->c out))] |
393 | 408 | [(Hashtable: k v)
|
394 | 409 | (when (equal? kind flat-sym) (exit (fail)))
|
395 | 410 | #`(hash/c #,(t->c k #:kind chaperone-sym) #,(t->c v) #:immutable 'dont-care)]
|
|
0 commit comments