File tree Expand file tree Collapse file tree 4 files changed +35
-11
lines changed
typed-racket-lib/typed-racket
typed-racket-test/succeed Expand file tree Collapse file tree 4 files changed +35
-11
lines changed Original file line number Diff line number Diff line change 13851385 (lambda (e)
13861386 (match-define (exn:fail:contract:arity:type-constructor _ _ expected given) e)
13871387 (err expected given))])
1388- (define alias (lookup-type-alias #'id (lambda (x) x) (lambda () #f )))
1389- (match alias
1390- [(? Name?)
1391- (if (equal? arity (length args^))
1392- (make-App alias args^)
1393- (err arity (length args^)))]
1394- [_ (apply rator args^)]))]
1388+ (cond
1389+ ;; in the checking mode, inline type applications of simple
1390+ ;; type constructors
1391+ [(and (not mode)
1392+ (simple-type-constructor? #'id ))
1393+ (apply rator args^)]
1394+ [else
1395+ (define alias (lookup-type-alias #'id (lambda (x) x) (lambda () #f )))
1396+ (match alias
1397+ [(? Name?)
1398+ (if (equal? arity (length args^))
1399+ (make-App alias args^)
1400+ (err arity (length args^)))]
1401+ [_ (apply rator args^)])]))]
13951402 [(? Name?)
13961403 (resolve-app-check-error rator args^ stx)
13971404 (define app (make-App rator args^))
Original file line number Diff line number Diff line change 1010 "../find-annotation.rkt "
1111 "../tc-metafunctions.rkt "
1212 "../../types/abbrev.rkt "
13- "../../types/resolve.rkt "
1413 "../../types/utils.rkt "
1514 "../../types/generalize.rkt "
15+ "../../types/resolve.rkt "
1616 "../../types/type-table.rkt "
1717 "../../private/type-annotation.rkt "
1818 "../../private/syntax-properties.rkt "
109109 (generalize (tc-expr/t ac)))))]
110110 [acc-ty (or
111111 (type-annotation #'val #:infer #t )
112- (match (resolve expected)
113- [(tc-result1: (app resolve (and t (Listof: _ )))) t]
112+ (match expected
113+ [(tc-result1: (and t (or (? App? (app resolve-once (Listof: _ ))) (Listof: _ ))))
114+ t]
114115 [_ #f ])
115116 (generalize -Null))])
116117 ;; this check is needed because the type annotation may come
Original file line number Diff line number Diff line change 1212 "../../types/type-table.rkt "
1313 "../../types/utils.rkt "
1414 "../../types/substitute.rkt "
15+ "../../types/resolve.rkt "
1516 "../../rep/type-rep.rkt "
1617 "../../env/tvar-env.rkt "
1718 (prefix-in i: "../../infer/infer.rkt " )
154155 ;; special case for `reverse' to propagate expected type info
155156 (pattern ((~and fun (~or reverse k:reverse)) arg)
156157 (match expected
157- [(tc-result1: (and return-ty (Listof: _ )))
158+ [(tc-result1: (and return-ty (or (? App? (app resolve-once ( Listof: _ ))) (Listof: _ ) )))
158159 (begin0
159160 (tc-expr/check #'arg expected)
160161 (add-typeof-expr #'fun (ret (-> return-ty return-ty))))]
Original file line number Diff line number Diff line change 1+ #lang typed/racket
2+
3+ (define-type (Assoc X Y) (Listof (Pairof X Y)))
4+
5+ (: f : (Listof Integer) (Listof String) -> (Listof (Pairof Integer String)))
6+ (define (f l m)
7+ (for/list : (Assoc Integer String) ([x : Integer (in-list l)]
8+ [y : String (in-list m)])
9+ (cons x y)))
10+
11+
12+ (define (g [l : (Listof Integer)] [m : (Listof String)]) : (Assoc Integer String)
13+ (for/list ([x (in-list l)]
14+ [y (in-list m)])
15+ (cons x y)))
You can’t perform that action at this time.
0 commit comments