diff --git a/collects/typed-scheme/typecheck/tc-app-unit.ss b/collects/typed-scheme/typecheck/tc-app-unit.ss index 6114a73981..6a012fd36a 100644 --- a/collects/typed-scheme/typecheck/tc-app-unit.ss +++ b/collects/typed-scheme/typecheck/tc-app-unit.ss @@ -108,7 +108,8 @@ [else (tc-error/delayed #:stx (car stxs) - "Wrong function argument type, expected ~a, got ~a for argument ~a" + "Wrong function argument type to ~a, expected ~a, got ~a for argument ~a" + (syntax->datum (current-orig-stx)) (car doms) (car args) arg-count) (loop (cdr args) (cdr doms) (cdr stxs) (add1 arg-count))])))) @@ -395,6 +396,7 @@ (define (tc/funapp f-stx args-stx ftype0 argtys expected) + ;(printf "~a~n" (syntax->datum f-stx)) (match-let* ([(list (tc-result: argtypes arg-thn-effs arg-els-effs) ...) argtys]) (let outer-loop ([ftype ftype0] [argtypes argtypes] @@ -694,7 +696,9 @@ "Cannot apply expression of type ~a, since it is not a function type" t)])] ;; even more special case for match [(#%plain-app (letrec-values ([(lp) (#%plain-lambda args . body)]) lp*) . actuals) - (and expected (not (andmap type-annotation (syntax->list #'args))) (free-identifier=? #'lp #'lp*)) + (begin + (printf "got here~n") + (and expected (not (andmap type-annotation (syntax->list #'args))) (free-identifier=? #'lp #'lp*))) (let-loop-check form #'lp #'actuals #'args #'body expected)] ;; or/andmap of ... argument [(#%plain-app or/andmap f arg) @@ -717,6 +721,7 @@ (tc/funapp #'f #'(args ...) (tc-expr #'f) (map tc-expr (syntax->list #'(args ...))) expected)])) (define (let-loop-check form lp actuals args body expected) + (printf "in let-loop-check~n") (kernel-syntax-case* #`(#,args #,body #,actuals) #f (null?) [((val acc ...) ((if (#%plain-app null? val*) thn els)) @@ -730,10 +735,13 @@ (or (find-annotation #'(if (#%plain-app null? val*) thn els) a) (generalize (tc-expr/t ac))))] [ts (cons ts1 ann-ts)]) + (printf "in body~n") ;; check that the actual arguments are ok here - (map tc-expr/check (syntax->list #'(actuals ...)) ann-ts) + (for-each tc-expr/check (syntax->list #'(actuals ...)) ann-ts) + (printf "checked args~n") ;; then check that the function typechecks with the inferred types - (tc/rec-lambda/check form args body lp ts expected) + (values #;debug (tc/rec-lambda/check form args body lp ts expected)) + (printf "done~n") (ret expected))] ;; special case when argument needs inference [_ diff --git a/collects/typed-scheme/typecheck/tc-toplevel.ss b/collects/typed-scheme/typecheck/tc-toplevel.ss index 5f2d36f25b..2c3aa72e28 100644 --- a/collects/typed-scheme/typecheck/tc-toplevel.ss +++ b/collects/typed-scheme/typecheck/tc-toplevel.ss @@ -40,7 +40,9 @@ ;; require/typed [(define-values () (begin (quote-syntax (require/typed-internal nm ty)) (#%plain-app values))) - (register-type #'nm (parse-type #'ty))] + (let ([t (parse-type #'ty)]) + (register-type #'nm t) + (list (make-def-binding #'nm t)))] ;; define-typed-struct [(define-values () (begin (quote-syntax (define-typed-struct-internal nm ([fld : ty] ...))) (#%plain-app values)))