File tree Expand file tree Collapse file tree 5 files changed +25
-3
lines changed
typed-racket-lib/typed-racket/typecheck Expand file tree Collapse file tree 5 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 1313 [cond-contracted tc-expr/check/t? (syntax? (or/c tc-results/c #f ) . -> . (or/c Type? #f ))]
1414 [cond-contracted tc-body/check (syntax? (or/c tc-results/c #f ) . -> . full-tc-results/c)]
1515 [cond-contracted tc-expr/t (syntax? . -> . Type?)]
16+ [cond-contracted tc-expr/t* (syntax? . -> . (values Type? boolean?))]
1617 [cond-contracted single-value ((syntax?) ((or/c tc-results/c #f )) . ->* . full-tc-results/c)]
1718 [cond-contracted tc-dep-fun-arg ((syntax?) ((or/c tc-results/c #f )) . ->* . full-tc-results/c)]))
1819
Original file line number Diff line number Diff line change 44(require "../../utils/utils.rkt "
55 "signatures.rkt "
66 "utils.rkt "
7- syntax/parse syntax/stx racket/match racket/sequence
7+ syntax/parse syntax/stx racket/match
88 (typecheck signatures tc-funapp error-message)
99 (types abbrev type-table utils substitute)
1010 (rep type-rep)
101101 ;; We want to infer the largest vs that are still under the element types
102102 (define substs (i:infer vs null (list l-type) (list t) (-values (list (-> l-type Univ)))
103103 #:multiple? #t ))
104+
104105 (cond
105106 [substs
106107 (define result
113114 (add-typeof-expr #'op-name (ret (->* arg-tys return-ty)))
114115 (ret return-ty)))
115116 (or result
116- (begin (expected-but-got t (-Tuple (map tc-expr/t args-list)))
117- (fix-results expected)))]
117+ (let-values ([(tys errs) (for/lists (tys errs)
118+ ([i (in-list args-list)])
119+ (tc-expr/t* i))])
120+ (when (andmap not errs)
121+ (expected-but-got t (-Tuple tys)))
122+ (fix-results expected)))]
118123 [else
119124 (define arg-tys (map tc-expr/t args-list))
120125 (define return-ty (-Tuple arg-tys))
Original file line number Diff line number Diff line change 6767 [(tc-result1: t _ _ ) t]
6868 [t (int-err "tc-expr returned ~a, not a single tc-result, for ~a " t (syntax->datum e))]))
6969
70+ (define (tc-expr/t* expr)
71+ (parameterize ([current-type-error? #f ])
72+ (values (tc-expr/t expr) (current-type-error?))))
73+
7074(define (tc-expr/check/t e t)
7175 (match (tc-expr/check e t)
7276 [(tc-result1: t) t]))
Original file line number Diff line number Diff line change 1+ #;
2+ (exn-pred #rx".*expected: Symbol.*given: String " )
3+ #lang typed/racket
4+
5+ (ann (list (symbol->string "10 " ))
6+ (Listof String))
Original file line number Diff line number Diff line change 34883488 (list (vector 1 2 3 ))
34893489 #:ret (tc-ret (-seq (-vec Univ)))
34903490 #:expected (tc-ret (-seq (-vec Univ)))]
3491+
3492+ [tc-err
3493+ (ann (list (symbol->string "10 " )) (Listof String))
3494+ #:ret (tc-ret (-lst -String))
3495+ #:expected (tc-ret (-lst -String))
3496+ #:msg #rx"expected: Symbol.*given: String.* " ]
34913497
34923498 ;; PR 14557 - apply union of functions with different return values
34933499 [tc-err
You can’t perform that action at this time.
0 commit comments