Skip to content

Commit 21f636e

Browse files
committed
fix bugs revealed by conditional contracts
1 parent 84ea027 commit 21f636e

File tree

5 files changed

+39
-38
lines changed

5 files changed

+39
-38
lines changed

typed-racket-lib/typed-racket/env/lexical-env.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
[lookup-obj-type/lexical ((Object?) (env? #:fail (or/c #f Type? (-> any/c (or/c Type? #f))))
3434
. ->* .
3535
(or/c Type? #f))]
36-
[lookup-alias/lexical ((identifier?) (env?) . ->* . (or/c Path? Empty?))])
36+
[lookup-alias/lexical ((identifier?) (env?) . ->* . (or/c OptObject? #f))])
3737

3838
;; used at the top level
3939
(define (add-props-to-current-lexical! ps)

typed-racket-lib/typed-racket/static-contracts/combinators/dep-function.rkt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@
8888

8989
(provide/cond-contract
9090
[struct ->i/sc ([typed-side? boolean?]
91-
[ids (listof identifier?)]
92-
[dom (listof static-contract?)]
93-
[dom-deps (listof (listof identifier?))]
94-
[pre (or/c #f proposition-contract?)]
95-
[pre-deps (listof (listof identifier?))]
96-
[rng (listof static-contract?)]
97-
[rng-deps (listof identifier?)])])
91+
[ids (listof identifier?)]
92+
[dom (listof static-contract?)]
93+
[dom-deps (listof (listof identifier?))]
94+
[pre (or/c #f proposition-contract?)]
95+
[pre-deps (listof identifier?)]
96+
[rng (listof static-contract?)]
97+
[rng-deps (listof identifier?)])])

typed-racket-lib/typed-racket/static-contracts/combinators/exist.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
(provide exist/sc:)
1313

1414
(provide/cond-contract
15-
[exist/sc ((listof identifier?) (listof static-contract?) (listof static-contract?) . -> . static-contract?)])
15+
[exist/sc ((listof identifier?) static-contract? static-contract? . -> . static-contract?)])
1616

1717

1818
(struct exist-combinator combinator ()

typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@
181181
(cond
182182
[(tc-expr/check? #'t.body expected)
183183
(tc-error/expr #:stx #'t.body (format "Expected a type check error!"))]
184-
[else expected])]
184+
[else
185+
(fix-results expected)])]
185186
;; data
186187
[(quote #f) (ret (-val #f) -false-propset)]
187188
[(quote #t) (ret (-val #t) -true-propset)]
@@ -294,34 +295,34 @@
294295
[_ (tc-expr/check form #f)])]
295296
;; opt function def
296297
[(~and (let-values ([(f) fun]) . body) opt:opt-lambda^)
297-
#:when expected
298-
(define conv-type
299-
(match expected
300-
[(tc-result1: fun-type)
301-
(match-define (list required-pos optional-pos optional-supplied?)
302-
(attribute opt.value))
303-
(opt-convert fun-type required-pos optional-pos optional-supplied?)]
304-
[_ #f]))
305-
(if conv-type
306-
(begin (tc-expr/check/type #'fun conv-type) expected)
307-
(tc-expr/check form #f))]
298+
#:when expected
299+
(define conv-type
300+
(match expected
301+
[(tc-result1: fun-type)
302+
(match-define (list required-pos optional-pos optional-supplied?)
303+
(attribute opt.value))
304+
(opt-convert fun-type required-pos optional-pos optional-supplied?)]
305+
[_ #f]))
306+
(if conv-type
307+
(begin (tc-expr/check/type #'fun conv-type) (fix-results expected))
308+
(tc-expr/check form #f))]
308309
[(~and _:kw-lambda^
309-
(let-values ([(f) fun])
310-
(let-values _
311-
(#%plain-app
312-
maker
313-
lambda-for-kws
314-
(case-lambda ; wrapper function
315-
(formals . cl-body) ...)
316-
(~or (quote (mand-kw:keyword ...))
317-
(~and _ (~bind [(mand-kw 1) '()])))
318-
(quote (all-kw:keyword ...))
319-
. rst))))
320-
(define p (plambda-property form))
321-
(ret (kw-unconvert (tc-expr/t (plambda-property #'fun p))
322-
(syntax->list #'(formals ...))
323-
(syntax->datum #'(mand-kw ...))
324-
(syntax->datum #'(all-kw ...))))]
310+
(let-values ([(f) fun])
311+
(let-values _
312+
(#%plain-app
313+
maker
314+
lambda-for-kws
315+
(case-lambda ; wrapper function
316+
(formals . cl-body) ...)
317+
(~or (quote (mand-kw:keyword ...))
318+
(~and _ (~bind [(mand-kw 1) '()])))
319+
(quote (all-kw:keyword ...))
320+
. rst))))
321+
(define p (plambda-property form))
322+
(ret (kw-unconvert (tc-expr/t (plambda-property #'fun p))
323+
(syntax->list #'(formals ...))
324+
(syntax->datum #'(mand-kw ...))
325+
(syntax->datum #'(all-kw ...))))]
325326
[(~and opt:opt-lambda^
326327
(let-values ([(f) fun])
327328
(case-lambda (formals . cl-body) ...)))

typed-racket-lib/typed-racket/types/subtype.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@
805805
[(case: F (F: var1))
806806
(match t2
807807
;; tvars are equal if they are the same variable
808-
[(F: var2) (eq? var1 var2)]
808+
[(F: var2) (and (eq? var1 var2) A)]
809809
[_ (continue<: A t1 t2 obj)])]
810810
[(case: Fun (Fun: arrows1))
811811
(match* (t2 arrows1)

0 commit comments

Comments
 (0)